spring-mybatis整合
程序员文章站
2022-07-04 09:39:35
spring-mybatis配置:
依赖导入:
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.2</version>
</dependency>
<!-- mybatis-plus 依赖 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>2.3</version>
<exclusions>
<exclusion>
<artifactId>mybatis-spring</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
</exclusions>
</dependency>
spring-mybatis配置:
<?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
">
<bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean">
<!-- 数据源 -->
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
<!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 -->
<property name="mapperLocations" value="classpath*:com/gogbuy/newversion/*/mapping/*.xml" />
<!-- 插件注册 -->
<property name="plugins">
<list>
<!-- 注册分页插件 -->
<bean class="com.github.pagehelper.PageInterceptor"></bean>
<bean class="com.baomidou.mybatisplus.plugins.PaginationInterceptor"></bean>
</list>
</property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.gogbuy.newversion.*" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManagerForMybatis" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource_jeecg" />
</bean>
<!--开启事务注解-->
<tx:annotation-driven transaction-manager="transactionManagerForMybatis"></tx:annotation-driven>
<!-- 拦截器方式配置事物 -->
<!--<tx:advice id="transactionAdvice1" transaction-manager="transactionManager1">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="append*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="modify*" propagation="REQUIRED" />
<tx:method name="edit*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="remove*" propagation="REQUIRED" />
<tx:method name="repair" propagation="REQUIRED" />
<tx:method name="delAndRepair" propagation="REQUIRED" />
<tx:method name="do*" propagation="REQUIRED" />
<tx:method name="get*" propagation="SUPPORTS" />
<tx:method name="find*" propagation="SUPPORTS" />
<tx:method name="load*" propagation="SUPPORTS" />
<tx:method name="search*" propagation="SUPPORTS" />
<tx:method name="datagrid*" propagation="SUPPORTS" />
<tx:method name="*" propagation="SUPPORTS" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="transactionPointcut1" expression="execution(* com.gogbuy.newversion.*.service.*.*(..))" />
<aop:advisor pointcut-ref="transactionPointcut1" advice-ref="transactionAdvice1" />
</aop:config>-->
</beans>
本文地址:https://blog.csdn.net/Stark_liu/article/details/108993200
上一篇: 花样使用Handler与源码分析
推荐阅读
-
搭建ssh框架的基本步骤(ssh框架整合实战教程)
-
Jsp和PHP共用80端口整合Apache和Tomcat(访问时无需加端口号)
-
Spring 整合 Hibernate 时启用二级缓存实例详解
-
springboot+springmvc+mybatis项目整合
-
vue-cli整合vuex的时候,修改actions和mutations,实现热部署的方法
-
使用spring整合Quartz实现—定时器功能
-
SSH整合中 hibernate托管给Spring得到SessionFactory
-
详解spring cloud整合Swagger2构建RESTful服务的APIs
-
内容营销不止是选内容,更要做立体式整合营销
-
要想品牌营销得好,怎么能没有全网整合营销?