【发布时间】:2015-05-19 00:56:50
【问题描述】:
我有一个多项目 gradle 项目:
ht-java
- ht 域
- ht-scraper
ht-scraper 使用位于 ht-domain 中的域模型和 daos。 当我启动 springboot 应用程序时,出现以下错误:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.hypetube.domain.dao.ChannelRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
当我在 ht-scraper 中有存储库类时,一切正常。
我的 Spring 应用如下所示:
@Configuration
@EnableAutoConfiguration
@ComponentScan({"com.hypetube", "com.hypetube.domain"})
@EnableConfigurationProperties //use this to register other properties sources e.g. property files
public class Application {
private static final Logger log = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
@Autowired
private Environment env;
@PostConstruct
public void printActiveSpringProfiles() {
log.info("Following spring profiles are active: {}", new ArrayList<>(Arrays.asList(env.getActiveProfiles())));
}
}
settings.gradle:
include 'ht-domain', 'ht-scraper'
build.gradle (ht.scraper):
compile project(":ht-domain")
一切正常;该项目编译没有错误是迫在眉睫。 就在我启动应用程序时发生错误。
【问题讨论】:
-
那个项目可以在线使用吗?
-
很遗憾不是,它是一个商业项目。我不能全部发布。会不会是子项目 jar 的清单有问题?清单目前为空
-
也许可以,很难说。如果可能,请提供重现错误的示例项目。
-
很好,稍后看看。
标签: gradle spring-boot