springkotlinspring-kotlin

Spring Kotlin @ConfigurationProperties for data class defined in dependency


I've got a library that has a configuration class (no spring configuration class) defined as a data class. I want a Bean of that configuration which can be configured via application.properties. The problem is that I don't know how to tell Spring to create ConfigurationProperties according to that external data class. I am not the author of the configuration class so I can't annotate the class itself. @ConfigurationProperties in conjunction with @Bean does not work as the properties are immutable. Is this even possible?


Solution

  • Maybe change scan packages to inlcude the packages that do you want.

     @SpringBootApplication( scanBasePackages = )
    

    take a look this: Configuration using annotation @SpringBootApplication