spring+mybatis+mysql 事务配置

1、首先我这是maven项目,所以你要在pom.xml文件里面加上需要用到的jar配置:



org.springframework
spring-tx
4.0.3.RELEASE




com.alibaba
druid
0.2.9



mysql
mysql-connector-java
5.0.5



org.springframework
spring-jdbc
3.2.6.RELEASE




org.springframework
spring-aspects
4.0.3.RELEASE



org.mybatis
mybatis-spring
1.2.1




org.mybatis
mybatis
3.2.3

 

2、config.properties内容,也就是数据库链接信息

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://192.168.1.133:3306/salt?characterEncoding=utf-8
jdbc.user=root
jdbc.password=root1234

 

3、Spring配置文件applicationContext.xml文件内容


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 

http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd 

http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx.xsd 

http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> 


 
 



init-method="init" destroy-method="close">














value="50" />
 

 

 





 





expression="execution(* * com.hskj.service.*.*(..))" />


   
   
      
         LOG4J
      
   
   
   
   
           
               
                   
               
           
       


 
    
    
 

注:本文主要列出事务配置,适用于会配置spring的人观看,初学者请先把spring基础配置搞懂,另外大家请注意不同的数据库,事务配置会有点差异,本文适用于mysql数据库

 

你可能感兴趣的:(spring+mybatis+mysql 事务配置)