0

I can't seem to get constructor binding to work for a properties file created with @ConfigurationProperties in my own auto-configuration module. The issue takes place using Spring Boot v3.1.2 with spring boot starter parent and Kotlin.

This code works perfectly when it is contained in the same module as the main module with the main class.

@ConfigurationProperties("eventsource.streams.aggregate")
data class KafkaStreamsProperties(
    val bootstrapServers: String,
    val applicationId: String,
    val eventTopic: String,
    val targetTopic: String
)

However, moving it into a separate lib maven module with

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>

I get met with Parameter 0 of constructor in no.holden.catalogs.libs.event.aggregate.KafkaStreamsProperties required a bean of type 'java.lang.String' that could not be found.

If i alter the class to be mutable e.g

@ConfigurationProperties("eventsource.streams.aggregate")
data class KafkaStreamsProperties(
    var bootstrapServers: String = "",
    var applicationId: String = "",
    var eventTopic: String = "",
    var targetTopic: String = ""
)

Everything works as expected again.

My org.springframework.boot.autoconfigure.AutoConfiguration.imports contains no.holden.catalogs.libs.event.aggregate.KafkaStreamsProperties

0 Answers0