一、修改配置文件
在ruoyi-admin/src/main/resources目录
1、修改数据库连接
2、修改redis连接
3、修改项目端口及根路径
4、修改日志存放路径。
二、改造项目为mybatisplus
1、在ruoyi-common/pom.xml里添加mybatisplus依赖
<!-- mybatisPlus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.5.1</version> </dependency>
2、注释src\main\java\com\ruoyi\framework\config\MyBatisConfig.java代码
3、在src\main\java\com\ruoyi\framework\config\创建MybatisPlusConfig.java文件
1 package com.ruoyi.framework.config; 2 3 import com.baomidou.mybatisplus.annotation.DbType; 4 import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; 6 import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; 7 import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 8 import org.springframework.context.annotation.Bean; 9 import org.springframework.context.annotation.Configuration; 10 import org.springframework.transaction.annotation.EnableTransactionManagement; 11 12 /** 13 * @USER: pkuokuo 14 * @DATE: 2024/12/17 16:53 15 * @DESCRIPTION: TODO 16 */ 17 @EnableTransactionManagement(proxyTargetClass = true) 18 @Configuration 19 public class MybatisPlusConfig { 20 @Bean 21 public MybatisPlusInterceptor mybatisPlusInterceptor() 22 { 23 MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); 24 // 分页插件 25 interceptor.addInnerInterceptor(paginationInnerInterceptor()); 26 // 乐观锁插件 27 interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor()); 28 // 阻断插件 29 interceptor.addInnerInterceptor(blockAttackInnerInterceptor()); 30 return interceptor; 31 } 32 33 /** 34 * 分页插件,自动识别数据库类型 https://baomidou.com/guide/interceptor-pagination.html 35 */ 36 public PaginationInnerInterceptor paginationInnerInterceptor() 37 { 38 PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(); 39 // 设置数据库类型为mysql 40 paginationInnerInterceptor.setDbType(DbType.MYSQL); 41 // 设置最大单页限制数量,默认 500 条,-1 不受限制 42 paginationInnerInterceptor.setMaxLimit(-1L); 43 return paginationInnerInterceptor; 44 } 45 46 /** 47 * 乐观锁插件 https://baomidou.com/guide/interceptor-optimistic-locker.html 48 */ 49 public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() 50 { 51 return new OptimisticLockerInnerInterceptor(); 52 } 53 54 /** 55 * 如果是对全表的删除或更新操作,就会终止该操作 https://baomidou.com/guide/interceptor-block-attack.html 56 */ 57 public BlockAttackInnerInterceptor blockAttackInnerInterceptor() 58 { 59 return new BlockAttackInnerInterceptor(); 60 } 61 }View Code
4、修改ruoyi-admin/src/main/resources/application.yml中mybatisplus配置文件
# MyBatis配置 #mybatis: # # 搜索指定包别名 # typeAliasesPackage: com.ruoyi.**.domain # # 配置mapper的扫描,找到所有的mapper.xml映射文件 # mapperLocations: classpath*:mapper/**/*Mapper.xml # # 加载全局的配置文件 # configLocation: classpath:mybatis/mybatis-config.xml # MyBatis Plus配置 mybatis-plus: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.**.domain # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath*:mapper/**/*Mapper.xml # 加载全局的配置文件 configLocation: classpath:mybatis/mybatis-config.xml
标签:mybatisplus,项目,ruoyi,baomidou,本地,import,interceptor,com From: https://www.cnblogs.com/pengpengdeyuan/p/18643479