I have the following project structure:
ApplicationConfiguration:
@Configuration
@ComponentScan(basePackages = {"configuration", "nsd"}) //<- base packages here
public class ApplicationConfiguration {
}
ApplicationProperties:
@Component
@EnableConfigurationProperties
public class ApplicationProperties {
...
MyRestController:
@RestController
public class MyRestController {
@Autowired
private ApplicationProperties properties; // <-- could not autowire
...
When I start application I see:
*************************** APPLICATION FAILED TO START
Description:
Field properties in nsd.MyRestController required a bean of type 'configuration.ApplicationProperties' that could not be found.
Action:
Consider defining a bean of type 'configuration.ApplicationProperties' in your configuration.
I don't understand why. ComponentScan provided in confuguration class.
How to fix this problem?
Update
If move ApplicationProperties to nsd
package - context up correctly but I still don't understand why doesn't it work from old package