Dim*_*iwa 2 java spring classpath spring-boot component-scan
在 Spring boot 1.5.9 应用程序中,我有@SpringBootApplication一个主类。
我也有@KopaxgroupApi注释,其中:
@Retention(RUNTIME)
@Target(TYPE)
@Import(KopaxgroupApiConfig.class)
public @interface KopaxgroupApi {
@AliasFor(annotation = Import.class, attribute = "value")
Class<?>[] value() default { KopaxgroupApiConfig.class };
}
Run Code Online (Sandbox Code Playgroud)
与KopaxgroupApiConfig.class是:
@Configuration
@ComponentScan(basePackages = { KopaxgroupApiConfig.CLASSPATH })
public class KopaxgroupApiConfig {
public static final String CLASSPATH = "com.kopaxgroup.api";
}
Run Code Online (Sandbox Code Playgroud)
我在其中创建了一个新项目,com.kopaxgroup.api.customerManagement.callMeBack并且将存储库和服务分别存储在目录repository和中service。
找不到.CallMeBackServiceImplCallMeBackRepository
我在启动时遇到以下错误:
Application failed to start due to an exception
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.kopaxgroup.api.customerManagement.callMeBack.repository.CallMeBackRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493)
Parameter 0 of constructor in com.kopaxgroup.api.customerManagement.callMeBack.service.impl.CallMeBackServiceImpl required a bean of type 'com.kopaxgroup.api.customerManagement.callMeBack.repository.CallMeBackRepository' that could not be found.
Action:
Consider defining a bean of type 'com.kopaxgroup.api.customerManagement.callMeBack.repository.CallMeBackRepository' in your configuration.
Run Code Online (Sandbox Code Playgroud)
我尝试CallMeBackRepository进入com.kopaxgroup.api.customerManagement.callMeBack.service.impl,但错误仍然存在。
我有一些类似的软件包,它们都可以启动,我没有看到配置有任何差异。
创建新罐子时会发生这种情况。
我添加了一堆@ComponentScan但无法解决它,我如何进一步挖掘并查看期间使用的类路径列表@ComponentScan("com.kopaxgroup.api")?
您可以查看 Springboot 中创建或拒绝的所有 bean 以及创建和拒绝的原因。
应用程序上下文中的 bean 列表由以下提供:ConditionEvaluationReportLoggingListener
要打印这些 bean:将其放入 application.propertieslogging.level.org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener=debug
我无法找到哪个包ConfigurationReportLoggingInitializer位于哪个包中,因为这是负责在 Springboot 版本 1.5.9 中打印 bean 的类。解决方法是提供以下属性:logging.level.root=debug. 然后按 CTRL + F ConfigurationReportLoggingInitializer。
| 归档时间: |
|
| 查看次数: |
1565 次 |
| 最近记录: |