调用mybatis-plus框架中的selectList方法
-
文件名没有问题
-
引用的包没有问题
-
mapper没有问题
-
怎么都找不到问题
项目使用了双数据源配置
- 去除另外一个配置的
@Primary
- 修改sqlSessionFactory方法
@Bean(name = "sqlSessionFactory")
public SqlSessionFactory testSqlSessionFactory(@Qualifier("dataSource") DataSource dataSource) throws Exception {
// 设置数据源
MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
mybatisSqlSessionFactoryBean.setDataSource(dataSource);
//mapper的xml文件位置
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
String locationPattern = "classpath*:/mapper/m1/*.xml";
mybatisSqlSessionFactoryBean.setMapperLocations(resolver.getResources(locationPattern));
//对应数据库的entity位置
String typeAliasesPackage = "com.local.native.entity";
mybatisSqlSessionFactoryBean.setTypeAliasesPackage(typeAliasesPackage);
mybatisSqlSessionFactoryBean.setDataSource(dataSource());
return mybatisSqlSessionFactoryBean.getObject();
}