Reputation: 85
I have created a configuration project which essentially creates couple of beans with configuration stereotype. Then, I want this project to be reused across by my clients. I have added this config project as a maven dependency, but my client project is not having those beans i have created as part of configuration project. Could someone help
Upvotes: 0
Views: 834
Reputation: 85
We can resolve this by enabling spring-boot autoconfiguration
Create classpath->resources->META-INF->spring.factories file org.springframework.boot.autoconfigure.EnableAutoConfiguration=[add your class with you need to be loaded during application load time]
Upvotes: 0
Reputation: 5911
Ok, the answer is the following: you should place
@ComponentScan("you.configurations.base.package")
on one of your configuration (in the current application, one that @SpringBootApplication
sees) or on the class with @SpringBootApplication
annotation.
The explanation is as follows: @SpringBootApplication
under the hood contains @ComponentScan
without specifying a base package. That means that it says to Spring to scan the package where the class annotated with @SpringBootApplication
resides and all the packages recursively. And that's it. If you place you @Configuration
somewhere there - it will create it during startup, otherwise not.
Upvotes: 1