Spring Boot version: 2.2.6 Project Type: Gradle based web application IDE: vscode
Hi, I read on a website that says "As, of Spring Boot 2.2, Spring finds and registers @ConfigurationProperties classes via classpath scanning. Therefore, there is no need to annotate such classes with @Component (and other meta-annotations like @Configuration) or even use the @EnableConfigurationProperties"
I interpret the above as: If a java class has this @ConfigurationProperties, it will be treated as a Spring bean. However, in my current app, this does not seem to be so. I have a Java class called MyAppProperties is being annotated with @ConfigurationProperties, but during app startup, autowiring could not find the bean of type MyAppProperties.
This issue goes away if i am to add a @Component to the MyAppProperties. So question is in spring bot 2.2, do we really need @Component or not???
Comment From: wilkinsona
The website is out of date. What it says was true for a time while Spring Boot 2.2 was being developed where configuration property scanning we enabled by default. This caused some problems so we changed it so that you have to opt in. You can do so by using @ConfigurationPropertiesScan. There's some more information about this in the reference documentation.
If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.