码迷,mamicode.com
首页 > 编程语言 > 详细

Consider defining a bean of type 'package' in your configuration [Spring-Boot]

时间:2017-07-05 01:18:43      阅读:1062      评论:0      收藏:0      [点我收藏+]

标签:body   ant   enable   structure   clu   ack   app   span   ons   

 

https://stackoverflow.com/questions/40384056/consider-defining-a-bean-of-type-package-in-your-configuration-spring-boot

 

Your Applicant class is not scanned it seems. By default all packages starting with the root as the class where you have put @SpringBootApplication will be scanned.

suppose your main class "WebServiceApplication" is in "com.service.something", then all components that fall under "com.service.something" is scanned, and "com.service.applicant" will not be scanned.

You can either restructure your packages such that "WebServiceApplication" falls under a root package and all other components becomes part of that root package. Or you can include @SpringBootApplication(scanBasePackages={"com.service.something","com.service.application"}) etc such that "ALL" components are scanned and initialized in the spring container.

Update based on comment

If you have multiple modules that are being managed by maven/gradle, all spring needs is the package to scan. You tell spring to scan "com.module1" and you have another module which has its root package name as "com.module2", those components wont be scanned. You can even tell spring to scan "com" which will then scan all components in "com.module1." and "com.module2."

 

 

 

 

 

I am not sure if it is because I have my project broke down in modules but this is how I solved my issue of not be able to find my repositories.

@SpringBootApplication
@ComponentScan({"com.delivery.request"})
@EntityScan("com.delivery.domain")
@EnableJpaRepositories("com.delivery.repository")

Consider defining a bean of type 'package' in your configuration [Spring-Boot]

标签:body   ant   enable   structure   clu   ack   app   span   ons   

原文地址:http://www.cnblogs.com/exmyth/p/7119225.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!