I am having two module web and business. I have included business in the web. But when I try to include a service interface from business into web using @autowired
,
@SpringBootApplication
only scans the packages of the class with the annotation itself and all packages below.
Example: If the class with the SpringBootApplication annotation is in the package com.project.web
, then this packages and all below that are scanned.
However, if you have your services in the package com.project.business
, the beans won't be scanned.
In that case you have to add the annotation @ComponentScan()
to your application class, and add all packages you want to scan as value in that annotation, e.g. @ComponentScan({"com.project.web", "com.project.business"})
.