When switching to 3.0.0 I have noticed that org.springframework.boot.context.properties.ConstructorBinding was deprecated in favor for org.springframework.boot.context.properties.bind.ConstructorBinding.
Unfortunately the @Target({ElementType.TYPE, ElementType.CONSTRUCTOR}) was changed to @Target({ ElementType.CONSTRUCTOR, ElementType.ANNOTATION_TYPE }) so instead of
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.ConstructorBinding
@ConstructorBinding
@ConfigurationProperties(prefix = "ff4j")
class FF4JProperties(
val jdbc: Jdbc,
val cacheTTL: Long,
) {
class Jdbc(
val url: String,
val username: String,
val password: String,
)
}
I have to write it like so
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.bind.ConstructorBinding
@ConfigurationProperties(prefix = "ff4j")
data class FF4JProperties @ConstructorBinding constructor(
val jdbc: Jdbc,
val cacheTTL: Long,
) {
data class Jdbc(
val url: String,
val username: String,
val password: String,
)
}
This is not really a problem but I find the ability to put it on type instead of on ctor cleaner.
Comment From: mhalbritter
Hey, if your class has only one constructor, you can drop the @ConstructorBinding annotation completely, see this comment for details. Does that help?
Comment From: delor
Yeah, thanks. I have missed that in migration guide but it's there. https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#constructingbinding-no-longer-needed-at-the-type-level