spring mybatis配置文件

<!-- 自动扫描bean,把作了注解的类转换为bean -->
<context:component-scan base-package="com.huawei.tbsc" annotation-config="true">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>

<!-- 读取资源文件 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:jdbc.properties" />
</bean>

<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">

<property name="driverClassName">
<value>${driver}</value>
</property>

<property name="url">
<value>${url}</value>
</property>

<property name="username">
<value>${username}</value>
</property>

<property name="password">
<value>${password}</value>
</property>

<!-- 数据库连接池最大连接数量 -->
<property name="maxActive">
<value>${maxActive}</value>
</property>

<!-- 数据库连接池最大空闲连接数量 -->
<property name="maxIdle">
<value>${maxIdle}</value>
</property>

<!-- 数据库连接池最大等待连接数量 -->
<property name="maxWait">
<value>${maxWait}</value>
</property>

</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:mybatis.xml" />
<property name="mapperLocations">
<list>
<value>classpath:com/huawei/tbsc/dao/impl/*-mapper.xml</value>
<value>classpath:com/huawei/tbsc/entity/*-resultMap.xml</value>
</list>
</property>
</bean>

<!-- 自动扫描Mapper接口,并实现其功能 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.huawei.tbsc.dao" />
<property name="markerInterface" value="com.huawei.tbsc.dao.base.BaseMapper" />
</bean>

<!-- 事务配置 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>

<tx:advice id="txAdvice" transaction-manager="transactionManager">

<tx:attributes>
<tx:method name="find*" propagation="REQUIRED" read-only="true" />
<tx:method name="page*" propagation="REQUIRED" read-only="true"/>
<tx:method name="select*" propagation="REQUIRED" read-only="true"/>
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
</tx:attributes>

</tx:advice>

<!-- 自动代理配置 -->
<aop:config>
<aop:pointcut expression="execution (* com.huawei.tbsc.service.impl.*.*(..))" id="service" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="service" />
</aop:config>

<!-- 标注类型 的事务配置 -->
<tx:annotation-driven transaction-manager="transactionManager" />
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值