Reputation: 87
I have Spring boot web app let's name it A and jar spring boot project let's name it B. There is dependency to jar B in pom file of Spring boot app A. DataSource is defined in app A. The question now is as follows: Is there possibility to autowire DataSource from app A in jar B? When I try to autowire there is warning: "Could not autowire. No beans of "DataSource" type found". Is there possibility to point spring boot in jar B, to autowire DataSource from dependent app? Any suggestions will be very helpful. Thank's a lot!
Upvotes: 0
Views: 234
Reputation: 2262
You can do that just add the @ComponentScan
annotation and include package of the first app to be scanned by Spring in the second app.
Here is something that you should do in the second app:
@ComponentScan("foo.bar")
@SpringBootApplication
Upvotes: 1