最近在搭建springboot继承dubbo的分布式项目时,测试dao层遇到的问题,启动测试方法时,出现如下错误:

java.lang.IllegalStateException: Found multiple @SpringBootConfiguration annotated classes [Generic bean: class [com.example.cqw.DubboDaoApplication]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [D:\study\dubbo-parent\dubbo-dao\target\classes\com\example\cqw\DubboDaoApplication.class], 
    at org.springframework.util.Assert.state(Assert.java:94)
    at org.springframework.boot.test.context.SpringBootConfigurationFinder.scanPackage(SpringBootConfigurationFinder.java:69)

如图:java.lang.IllegalStateException: Found multiple @SpringBootConfiguration annotated classes

 

 

分析原因:因为项目是springboot+dubbo架构,dao项目依赖于pojo项目,在pojo项目中也有启动类@SpringBootApplication,因为在dao的测试类中启动方法时,会加载pojo项目启动类,所以会造成上图所示错误,注释掉pojo项目启动类上的@SpringBootApplication注解即可

 

简单的说,就是你在项目中有两个@SpringBootApplication,注释掉一个你不用的就可以。

相关文章:

  • 2021-04-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
猜你喜欢
  • 2022-12-23
  • 2021-05-16
  • 2022-02-21
  • 2022-12-23
  • 2022-12-23
  • 2021-08-22
相关资源
相似解决方案