在 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 };
}
存在KopaxgroupApiConfig.class
:
@Configuration
@ComponentScan(basePackages = { KopaxgroupApiConfig.CLASSPATH })
public class KopaxgroupApiConfig {
public static final String CLASSPATH = "com.kopaxgroup.api";
}
我已经在其中创建了一个新项目,com.kopaxgroup.api.customerManagement.callMeBack
并且我将存储库和服务分别存储在目录repository
和service
.
CallMeBackServiceImpl
找不到CallMeBackRepository
. _
我在启动时遇到以下错误:
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.
我试图搬进CallMeBackRepository
去com.kopaxgroup.api.customerManagement.callMeBack.service.impl
,但错误仍然存在。
我有一些类似的软件包,它们都可以启动,我看不出配置有什么不同。
创建新 jar 时会发生这种情况。
我已经添加了一堆@ComponentScan
但我无法解决它,我怎样才能进一步挖掘并查看期间使用的类路径列表@ComponentScan("com.kopaxgroup.api")
?