1

I have the following project structure:
enter image description here

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

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

0 Answers0