chi
07/23/2023, 12:28 PM@Component
@ConfigurationProperties("testconfig")
data class TestConfiguration(var eyes: String, var nose: String)
I can see the property in the application.properties
file but, in the repository where I want to use this component, I see an error "could not autowire"
, and when I run the app it crashes because it couldn’t find TestConfiguration
, how do I fix this please?Chris Lee
07/23/2023, 2:32 PM@EnableConfigurationPropertis
referencing this class.chi
07/23/2023, 3:11 PM@SpringBootApplication
annotated class?Chris Lee
07/23/2023, 3:11 PMchi
07/23/2023, 3:14 PM@ConfigurationProperties
annotated class, and used it with @EnableConfigurationProperties
and that one works, I’m new to spring so I’m trying to do the same thing using the @Component
on the class, this doesn’t use the enable approach so I expected it to work without needing to use that other approachChris Lee
07/23/2023, 3:15 PM@EnableConfigurationProperties
(which register the class for properties binding) and @ConfigurationProperties
(which specifies the binding prefix).Chris Lee
07/23/2023, 3:15 PMchi
07/23/2023, 3:18 PMChris Lee
07/23/2023, 3:20 PMpublic fun frontEndModuleBeans(): BeanDefinitionDsl = beans {
configurationPropertiesBean<FrontEndProperties>(prefix = "frontend")
}
chi
07/23/2023, 3:25 PMChris Lee
07/23/2023, 3:26 PMchi
07/23/2023, 3:26 PMchi
07/23/2023, 3:27 PMchi
07/23/2023, 3:27 PMChris Lee
07/23/2023, 3:28 PM