SpringBoot error: Consider defining a bean of type 'com.mapper.UserMapper' cannot find the bean.

The valuationMapper in com.xxxxx.service.tour.impl.ValuationServiceImpl expects a bean of type 'com.xxxxx.mapper.evaluation.ValueionMapper' but could not find that bean.

analyze:

1、确认是否存在 ValueionMapper 接口的实现类,并且实现类被正确注入到 valuationMapper 属性中。

2、检查Mapper接口的扫描配置,确保包路径正确,能够扫描到 com.xxxxx.mapper.evaluation 包下的Mapper接口。

3、确认Mapper接口的命名与实现类的命名是否匹配。

1. Configure MybatisPlusConfig

@Configuration
@MapperScan("com.xxxxxx.mapper")
public class MybatisPlusConfig {
    /**
     * 分页插件
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}

yaml configuration

#mybatisPlus配置
  mybatis-plus:
    configuration:
      #开启驼峰映射
      map-underscore-to-camel-case: true
    #xml映射地址
    mapper-locations: classpath*:mapper/*.xml

Restart

 

Guess you like

Origin blog.csdn.net/weixin_56602545/article/details/130622442