已经在application.properties文件中配置了:
mybatis.mapper-locations=classpath:com/hzitshop/mapper/*Mapper.xml
mybatis.typeAliasesPackage=com.baomidou.springboot.entity
求大神帮忙
请问你是怎么解决的 我也遇到这个问题了
您好,我也遇到了该问题,想咨询下怎么解决的, 18551855681 盼联系
@Configuration
public class MybatisPlusConfig {
@Resource
private DataSource dataSource;
@Resource
private MybatisProperties properties;
@Resource
private ResourceLoader resourceLoader = new DefaultResourceLoader();
@Autowired(required = false)
private Interceptor[] interceptors;
@Autowired(required = false)
private DatabaseIdProvider databaseIdProvider;
/**
* 配置分页
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
/**
* 这里全部使用mybatis-autoconfigure 已经自动加载的资源。不手动指定
* 配置文件和mybatis-boot的配置文件同步
* @return
*/
@Bean
public MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean() {
MybatisSqlSessionFactoryBean mybatisPlus = new MybatisSqlSessionFactoryBean();
mybatisPlus.setDataSource(dataSource);
mybatisPlus.setVfs(SpringBootVFS.class);
if (StringUtils.hasText(this.properties.getConfigLocation())) {
mybatisPlus.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
}
//mybatisPlus.setConfiguration(properties.getConfiguration());
if (!ObjectUtils.isEmpty(this.interceptors)) {
mybatisPlus.setPlugins(this.interceptors);
}
MybatisConfiguration mc = new MybatisConfiguration();
mc.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
mybatisPlus.setConfiguration(mc);
if (this.databaseIdProvider != null) {
mybatisPlus.setDatabaseIdProvider(this.databaseIdProvider);
}
if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
mybatisPlus.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
}
if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
mybatisPlus.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
}
if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
mybatisPlus.setMapperLocations(this.properties.resolveMapperLocations());
}
return mybatisPlus;
}
}
如果提示自己dao方法找不到就需要修改yml配置文件mybatis-plus 为 mybatis 我用的是3.0.6版本。
核心原因不是别的原因而是将分页关键字机 LIMIT和PAGE关键字当成数据库统一默认的字段了,解决方案:添加 注解 @TableField(exist = false)
@TableField(exist = false)
private Integer page;
@TableField(exist = false)
private Integer limit;