ruoyi配置mybatis-flex(转)
·
ruoyi改造mybaits为mybatis-flex,我个人根据gitee上的文档,验证了一下,验证版本是ruoyi-vue-3.9.0。
原本链接为:[使用问题]: ruoyi配置mybatis-flex · Issue #I7UX96 · MyBatis-Flex/MyBatis-Flex - Gitee.com
使用时遇到的问题描述:
- common的pom添加
<!-- mybatis-flex包 -->
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
<version>1.6.3</version>
</dependency>
<!-- mybatis-flex-processor包 -->
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-processor</artifactId>
<version>1.6.3</version>
<scope>provided</scope>
</dependency>
- 修改配置application.xml
修改MyBatis配置为,主要是把自动生成ID关掉,否则插入后不返回ID
# MyBatis配置
mybatis-flex:
# 搜索指定包别名
type-aliases-package: com.ruoyi.**.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mapper-locations: classpath*:mapper/**/*Mapper.xml
configuration:
# 自动驼峰命名规则(camel case)映射
mapUnderscoreToCamelCase: true
# MyBatis 自动映射策略
# NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
autoMappingBehavior: FULL
# MyBatis 自动映射时未知列或未知属性处理策
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
autoMappingUnknownColumnBehavior: NONE
# 原理的mybatis配置
cacheEnabled: true
defaultExecutorType: SIMPLE
logImpl: org.apache.ibatis.logging.slf4j.Slf4jImpl
- 处理分页
修改common的pom处的分页插件
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.3.3</version>
</dependency>
- 修改MyBatisConfig
手动注入分页组件,否则分页失败。
@Configuration
public class MyBatisConfig {
@Autowired
private Environment env;
static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
@Bean
public PageInterceptor pageInterceptor() {
return new PageInterceptor();
}
}
- 修改spring-devtools.properties
修改admin的resource中的spring-devtools.properties,否则getById失败。添加
restart.include.mapper=/mapper-[\\w-\\.].jar
restart.include.pagehelper=/pagehelper-[\\w-\\.].jar
restart.include.mybatis-flex=/mybatis-flex-[\\w-\\.]+jar
关联版本:
1.6.3
ps:1.6.4貌似不行
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)