<!--自动扫描bean,把作了注解的类转换为bean-->
<context:component-scanbase-package="com.huawei.tbsc"annotation-config="true">
<context:exclude-filtertype="annotation"expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!--读取资源文件-->
<beanclass="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<propertyname="location"value="classpath:jdbc.properties"/>
</bean>
<!--配置数据源-->
<beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource">
<propertyname="driverClassName">
<value>${driver}</value>
</property>
<propertyname="url">
<value>${url}</value>
</property>
<propertyname="username">
<value>${username}</value>
</property>
<propertyname="password">
<value>${password}</value>
</property>
<!--数据库连接池最大连接数量-->
<propertyname="maxActive">
<value>${maxActive}</value>
</property>
<!--数据库连接池最大空闲连接数量-->
<propertyname="maxIdle">
<value>${maxIdle}</value>
</property>
<!--数据库连接池最大等待连接数量-->
<propertyname="maxWait">
<value>${maxWait}</value>
</property>
</bean>
<beanid="sqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean">
<propertyname="dataSource"ref="dataSource"/>
<propertyname="configLocation"value="classpath:mybatis.xml"/>
<propertyname="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接口,并实现其功能-->
<beanclass="org.mybatis.spring.mapper.MapperScannerConfigurer">
<propertyname="basePackage"value="com.huawei.tbsc.dao"/>
<propertyname="markerInterface"value="com.huawei.tbsc.dao.base.BaseMapper"/>
</bean>
<!--事务配置-->
<beanid="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<propertyname="dataSource"ref="dataSource"/>
</bean>
<tx:adviceid="txAdvice"transaction-manager="transactionManager">
<tx:attributes>
<tx:methodname="find*"propagation="REQUIRED"read-only="true"/>
<tx:methodname="page*"propagation="REQUIRED"read-only="true"/>
<tx:methodname="select*"propagation="REQUIRED"read-only="true"/>
<tx:methodname="delete*"propagation="REQUIRED"/>
<tx:methodname="add*"propagation="REQUIRED"/>
<tx:methodname="insert*"propagation="REQUIRED"/>
<tx:methodname="update*"propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<!--自动代理配置-->
<aop:config>
<aop:pointcutexpression="execution(*com.huawei.tbsc.service.impl.*.*(..))"id="service"/>
<aop:advisoradvice-ref="txAdvice"pointcut-ref="service"/>
</aop:config>
<!--标注类型的事务配置-->
<tx:annotation-driventransaction-manager="transactionManager"/>