当出现 如下 问题时:

Parameter 0 of constructor in '' 
required a bean of type '' 
that could not be found.

问题可能出现的原因,是包扫描不对
修改两个地方:

  • 启动类,扫描包的注解
  • yml文件mybatis-plus.mapper-locations的值

启动类

@SpringBootApplication
@EnableWisecoConfigCenter
@ComponentScan(value={"com.wiseco.decision","com.wisecoprod.report","com.wisecoprod.report"})
public class MonitorApplication {
    public static void main(String[] args) {
        SpringApplication.run(MonitorApplication.class, args);
    }
}

修改成

@SpringBootApplication
@EnableWisecoConfigCenter
@ComponentScan(value={"com.wiseco.model","com.wisecoprod.report"})
public class MonitorApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(MonitorApplication.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(MonitorApplication.class, args);
    }
}

yml文件

mybatis-plus:
  enable: true
  global-config:
    db-config:
      id-type: none
  mapper-locations: classpath*:/mybatis/**/*.xml,classpath*:/mapping/**/*.xml
  type-aliases-package: com.wiseco.model.**.entity
  type-enums-package: com.wiseco.model.service.commons.enums
#jwt:

修改成

mybatis-plus:
  enable: true
  global-config:
    db-config:
      id-type: none
  mapper-locations: classpath*:/mybatis/**/*.xml,classpath*:/mapping/**/*.xml,classpath*:/mapper/**/*.xml
  type-aliases-package: com.wiseco.model.**.entity
  type-enums-package: com.wiseco.model.service.commons.enums
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐