applicationContext.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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:db.properties</value>
</list>
</property>
</bean>
<bean id="dbcp_bean" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${db_driver}"></property>
<property name="url" value="${db_url}"></property>
<property name="username" value="${db_username}"></property>
<property name="password" value="${db_password}"></property>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dbcp_bean"></property>
<property name="typeAliasesPackage" value="com.gjy.model"></property>
<property name="plugins">
<list>
<ref bean="pageHelper_bean"/>
</list>
</property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.gjy.dao"></property>
</bean>
<bean id="pageHelper_bean" class="com.github.pagehelper.PageHelper">
<property name="properties">
<props>
<prop key="dialect">mysql</prop>
</props>
</property>
</bean>
<bean id="transactionManager_bean" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dbcp_bean"></property>
</bean>
<tx:advice id="tx_advice" transaction-manager="transactionManager_bean">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" isolation="DEFAULT" rollback-for="java.lang.NullPointerException" />
<tx:method name="modify*" propagation="REQUIRED" isolation="READ_COMMITTED" no-rollback-for="java.lang.NullPointerException"/>
<tx:method name="remove*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="aop_pointcut" expression="execution(* com.gjy.serviceImpl.*.*(..))"/>
<aop:advisor pointcut-ref="aop_pointcut" advice-ref="tx_advice"/>
</aop:config>
</beans>
附1:数据源文件(db.properties)
db_driver=com.mysql.jdbc.Driver
db_url=jdbc:mysql://localhost:3306/db_ssm?useUnicode=true&characterEncoding=UTF-8
db_username=root
db_password=root
附2:该配置文件的源码目录结构
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190504215322865.)
附3:该配置文件所用到的jar包
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190504215619646.)