https://kotlinlang.org logo
#spring
Title
# spring
d

DosExe

08/25/2020, 3:57 PM
Hi, I have a problem with spring boot 2.1.6 I tried to use kotlin bean dsl to declare beans and it works perfectly fine for the core app, but tests are failing (for tests I am using spring-boot-starter-test and kotest). I have read all the information I could find on stackoverflow and made these improvements: 1. Created
Copy code
class BeansInitializer : ApplicationContextInitializer<GenericApplicationContext> {
   override fun initialize(context: GenericApplicationContext) {
       beans().initialize(context)
   }
}
2. Set context.initializer.classes=com.package.BeansInitializer in application.properties It helped a little bit, now some of the beans are created, but all beans with @ConfigurationsProperties are still not created.
👀 1
t

thanksforallthefish

08/26/2020, 6:38 AM
I actually never tried the dsl (still want to), but we annotation driven configuration a
@ConfigurationProperties
needs to an
@Component
or being declared in an
@EnableConfigurationProperties(MyProperty)
(don’t remember the syntax by heart). What is the equivalent with the dsl and are you sure the class enabling properties is picked by your tests? also, SpringBoot 2.1 is pretty old, lots of kotlin support was added in 2.2, consider upgrading if manageable
d

DosExe

08/26/2020, 6:40 AM
@Component is there, it isn't working in pure spring without it
dsl should work with annotation in other classes as well, so i have the bean dsl and near some classes with annotations such as @Service or @ConfigurationProperties
3 Views