Spring Boot can't autowire @ConfigurationProperties

This is expected as @ConfigurationProperties does not make a class a Spring Component. Mark the class with @Component and it should work. Note that a class can only be injected if it is a Component.

Edit: From Spring 2.2+ (Reference) @ConfigurationProperties scanning Classes annotated with @ConfigurationProperties can now be found via classpath scanning as an alternative to using @EnableConfigurationProperties or @Component. Add @ConfigurationPropertiesScan to your application to enable scanning.


Try to annotate with @ConfigurationProperties and @Component

In here , Spring Boot @ConfigurationProperties is annotation for externalized configuration.if you are trying to inject property value from a property file to a class, you can add @ConfigurationProperties at a class level with stereotype annotations such as @Component or add @ConfigurationProperties to a @Bean method.