• 首页
  • 栏目
  • CRM
  • Parameter 0 of constructor in ‘‘ required a bean of type ‘‘ that could not be found.

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

  • 2021-11-03
  • Admin

当出现 如下 问题时:

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

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

  • 启动类,扫描包的注解
  • 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);
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

修改成

@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);
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

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:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

修改成

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

原文:https://blog.csdn.net/weixin_43286124/article/details/121120477

联系站长

QQ:769220720