如何在beans.xml中添加多个dao以及mapper.xml
来源:互联网 发布:软件的健壮性 编辑:程序博客网 时间:2024/06/03 05:49
现在我的项目目录为如下图
在beans.xml中添加dao和mapper.xml 配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
<context:annotation-config></context:annotation-config>
<context:component-scan base-package="com.zhidao.oms">
</context:component-scan>
<context:property-placeholder location="classpath:db.properties" />
<!-- datasource -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!-- results in a setDriverClassName(String) call -->
<property name="driverClassName" value="${jdbc.driverClass}"/>
<property name="url" value="${jdbc.jdbcUrl}"/>
<property name="username" value="${jdbc.user}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<!-- sessionfactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!--导入多个mapper.xml-->
<property name="mapperLocations" value="classpath:com/zhidao/oms/**/mapper/*.xml"></property>
<property name="configLocation" value="classpath:mybatis.cfg.xml"></property>
</bean>
<!-- dao注入 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--导入多个dao->
<property name="basePackage" value="com.zhidao.oms.product.dao,com.zhidao.oms.shop.dao,com.zhidao.oms.type.dao,com.zhidao.oms.user.dao" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!-- transaction -->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- aspect -->
<aop:config>
<aop:pointcut id="businessService"
expression="execution(public * com.zhidao.oms..serviceimpl..*.*(..))"/>
<aop:advisor pointcut-ref="businessService" advice-ref="tx-advice"/>
</aop:config>
<tx:advice id="tx-advice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
</beans>
- 如何在beans.xml中添加多个dao以及mapper.xml
- Mybatis中通过generator生成mapper、Dao、mapper.xml
- 如何通过mybatis逆向工程生成实体类以及dao和mapper.xml
- 如何在mybatis中定义mapper.xml文件?
- Mapper.xml文件中如何判断多个参数不为空和null
- 使用mybatis时Mapper.xml文件中如何判断多个参数不为空和null
- 使用mybatis自带工具,自动生成表对应domain、mapper.xml以及dao
- 使用mybatis自带工具,自动生成表对应domain、mapper.xml以及dao
- 使用mybatis自带工具,自动生成表对应domain、mapper.xml以及dao
- 使用mybatis自带工具,自动生成表对应domain、mapper.xml以及dao
- 如何在web.xml中加载外部多个xml文件
- 如何在web.xml中加载外部多个xml文件
- 给表添加记录时,在mapper.xml中配置sql,需要添加主键值的写法
- 如何让spring开发中beans.xml出现属性提示
- 在 XML 中添加实体
- 在XML中添加实体
- 在xml中添加array
- 如何在xml中直接添加view点击监听
- Select2下拉选项库 部分积累
- CMap如何key为字符串,值为int
- hdoj 2504又见GCD
- nyoj 91 阶乘之和
- 用于HDMI接口的ESD保护技术
- 如何在beans.xml中添加多个dao以及mapper.xml
- orbslam2的基础理论(一)
- 如何理解BGP同步规则-
- HTML特殊字符的html、js、css写法汇总
- Makefile (三) 总述
- Git命令行下自动保存用户名和密码
- [主席树区间覆盖 线段树] UNR #1 火车管理
- Android短信发送,监听,及其工具类封装
- ubuntu14.04系统相关