作者在 2021-01-04 01:49:30 发布以下内容
若依默认使用的是mybatis,改成mybatis-plus后一些配置也需要修改:
1、把application.yml中的mybatis:改成mybatis-plus:,删除下面的configLocation: classpath:mybatis/mybatis-config.xml,同时相关的配置文件ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml也可以删除了
2、全局搜索SqlSessionFactory,删除ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java中的SqlSessionFactory相关的Bean,就是下面这一段删除掉:
@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 SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
return sessionFactory.getObject();
}