若依集成mybatisplus报错找不到xml

引用:https://blog.csdn.net/qq_65080131/article/details/136677276

MybatisPlusAutoConfiguration中可以知道,系统会自动配置SqlSessionFactory,,但是,当你有自定义的SqlSessionFactory,,就会出问题,,,,

若依中的SqlSessionFactory 不是 MybatisSqlSessionFactory

所以需要,将SqlSessionFactory 换成,MybatisSqlSessionFactory

java 复制代码
    @Bean
    public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
    {
        String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
        String mapperLocations = env.getProperty("mybatis.mapperLocations");
        String configLocation = env.getProperty("mybatis.configLocation");
        typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
        VFS.addImplClass(SpringBootVFS.class);
 
        final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
        sessionFactory.setDataSource(dataSource);
        sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
        sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
        sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
        return sessionFactory.getObject();
    }
相关推荐
Nyarlathotep011313 小时前
SpringBoot Starter的用法以及原理
java·spring boot
wuwen513 小时前
WebFlux + Lettuce Reactive 中 SkyWalking 链路上下文丢失的修复实践
java
SimonKing13 小时前
GitHub 10万星的OpenCode,正在悄悄改变我们的工作流
java·后端·程序员
Seven9714 小时前
虚拟线程深度解析:轻量并发编程的未来趋势
java
雨中飘荡的记忆1 天前
ElasticJob分布式调度从入门到实战
java·后端
考虑考虑1 天前
JDK25模块导入声明
java·后端·java ee
_小马快跑_1 天前
Java 的 8 大基本数据类型:为何是不可或缺的设计?
java
Re_zero2 天前
线上日志被清空?这段仅10行的 IO 代码里竟然藏着3个毒瘤
java·后端
洋洋技术笔记2 天前
Spring Boot条件注解详解
java·spring boot
程序员清风2 天前
程序员兼职必看:靠谱软件外包平台挑选指南与避坑清单!
java·后端·面试