//www.springframework.org/schema/beans"
xmlns:
xsi="http:
//www.w3.org/2001/XMLSchema-instance"
xmlns:
aop="http:
//www.springframework.org/schema/aop"
xmlns:
context="http:
//www.springframework.org/schema/context"
xmlns:
jdbc="http:
//www.springframework.org/schema/jdbc"
xmlns:
p="http:
//www.springframework.org/schema/p"
xmlns:
tx="http:
//www.springframework.org/schema/tx"
xmlns:
util="http:
//www.springframework.org/schema/util"
xsi:
schemaLocation="http:
//www.springframework.org/schema/beanshttp:
//www.springframework.org/schema/beans/spring-beans.xsd
http:
//www.springframework.org/schema/aophttp:
//www.springframework.org/schema/aop/spring-aop-4.1.xsd
http:
//www.springframework.org/schema/contexthttp:
//www.springframework.org/schema/context/spring-context-4.1.xsd
http:
//www.springframework.org/schema/jdbchttp:
//www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
http:
//www.springframework.org/schema/txhttp:
//www.springframework.org/schema/tx/spring-tx-4.1.xsd
http:
//www.springframework.org/schema/utilhttp:
//www.springframework.org/schema/util/spring-util-4.1.xsd">
--加载数据库配置文件-->
property-placeholderlocation="classpath:
resource/db.properties"/>
--配置数据源-->
--数据库连接池-->
destroy-method="close">
--配置SqlSessionFactory-->
--配置数据源-->
--配置MyBatis路径-->
mybatis/mybatis-config.xml">
--Mapper文件扫描器-->
该配置文件主要是spring整合mybatis文件。
2.6、Spring事务管理
创建applicationContext-trans.xml位于spring文件夹下
applicationContext-trans.xml
xmlversion="1.0"encoding="UTF-8"?
>
//www.springframework.org/schema/beans"
xmlns:
xsi="http:
//www.w3.org/2001/XMLSchema-instance"
xmlns:
context="http:
//www.springframework.org/schema/context"
xmlns:
jdbc="http:
//www.springframework.org/schema/jdbc"
xmlns:
p="http:
//www.springframework.org/schema/p"
xmlns:
tx="http:
//www.springframework.org/schema/tx"
xmlns:
util="http:
//www.springframework.org/schema/util"
xmlns:
aop="http:
//www.springframework.org/schema/aop"
xsi:
schemaLocation="http:
//www.springframework.org/schema/jdbchttp:
//www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
http:
//www.springframework.org/schema/beanshttp:
//www.springframework.org/schema/beans/spring-beans.xsd
http:
//www.springframework.org/schema/contexthttp:
//www.springframework.org/schema/context/spring-context-4.1.xsd
http:
//www.springframework.org/schema/aophttp:
//www.springframework.org/schema/aop/spring-aop-4.1.xsd
http:
//www.springframework.org/schema/txhttp:
//www.springframework.org/schema/tx/spring-tx-4.1.xsd
http:
//www.springframework.org/schema/utilhttp:
//www.springframework.org/schema/util/spring-util-4.1.xsd">
--配置事务管理器-->
--配置数据源-->
--配置事务-->
adviceid="txAdvice"transaction-manager="transactionManager">
attributes>
methodname="save*"propagation="REQUIRED"/>
methodname="insert*"propagation="REQUIRED"/>
methodname="add*"propagation="REQUIRED"/>
methodname="create*"propagation="REQUIRED"/>
methodname="delete*"propagation="REQUIRED"/>
methodname="update*"propagation="REQUIRED"/>
methodname="find*"propagation="SUPPORTS"read-only="true"/>
methodname="select*"propagation="SUPPORTS"read-only="true"/>
methodname="get*"propagation="SUPPORTS"read-only="true"/>
attributes>
advice>
--切面-->
config>
advisoradvice-ref="txAdvice"
pointcut="execution(*com.taotao.service.impl.*.*(..))"/>
config>
该配置文件主要配置事务以及事务管理和切面(AOP)配置。
2.7、Spring扫描Service的实现类
创建applicationContext-service.xml位于spring文件夹下
applicationContext-service-xml
xmlversion="1.0"encoding="UTF-8"?
>
//www.springframework.org/schema/beans"
xmlns:
xsi="http:
//www.w3.org/2001/XMLSchema-instance"
xmlns:
aop="http:
//www.springframework.org/schema/aop"
xmlns:
context="http:
//www.springframework.org/schema/context"
xmlns:
jdbc="http:
//www.springframework.org/schema/jdbc"
xmlns:
p="http:
//www.springframework.org/schema/p"
xmlns:
tx="http:
//www.springframework.org/schema/tx"
xmlns:
util="http:
//www.springframework.org/schema/util"
xsi:
schemaLocation="http:
//www.springframework.org/schema/beanshttp:
//www.springframework.org/schema/beans/spring-beans.xsd
http:
//www.springframework.org/schema/aophttp:
//www.springframework.org/schema/aop/spring-aop-4.1.xsd
http:
//www.springframework.org/schema/contexthttp:
//www.springframework.org/schema/context/spring-context-4.1.xsd
http:
//www.springframework.org/schema/jdbchttp:
//www.springframework.org/schema/jdbc/spring-jdbc-4.1