<!--扫描除了controller的包-->
<context:component-scan base-package="cn.kgc">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!--引入外部资源-->
<context:property-placeholder location="classpath:db.properties"/>
<!--配置数据源-->
<bean class="com.mchange.v2.c3p0.ComboPooledDataSource" id="dataSource">
<property name="driverClass" value="${}"/>
<property name="driverClass" value="${}"/>
<property name="driverClass" value="${}"/>
<property name="driverClass" value="${}"/>
</bean>
<!--mybatis接口放入ioc中-->
<bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory">
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath:mapper/*"/>
</bean>
<!--批量处理数据-->
<bean class="org.mybatis.spring.SqlSessionTemplate" id="sqlsession">
<constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"/>
<constructor-arg name="executorType" value="BATCH"/>
</bean>
<!--mybatis接口实现放入ioc中-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="cn.kgc.cy.ssmcrud.dao"/>
</bean>
<!--配置事务的事务-->
<bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" id="transactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!--开启注解的配置-->
<aop:config>
<aop:pointcut id="txpoint" expression="execution(* cn.kgc.cy.ssmcrud.service..*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txpoint"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*"/>
<tx:method name="get*" read-only="true"/>
</tx:attributes>
</tx:advice>
ssmcrud的applicationContext.xml配置