-
Notifications
You must be signed in to change notification settings - Fork 41.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@ConfigurationProperties recommendation for Kotlin doesn't produce metadata properties #42314
Comments
I just found this issue after trying to figure out why the official guide doesn't work, when applied on current versions (Gradle 8.10, Kotlin 2.0.20, JDK 22, Spring Boot 3.3.3) |
I've noticed the when I set import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.bind.ConstructorBinding
import org.springframework.boot.context.properties.bind.DefaultValue
@ConfigurationProperties(prefix = QueryLoggingConfigurationProperties.PREFIX)
data class QueryLoggingConfigurationProperties @ConstructorBinding constructor(
@DefaultValue("false")
val enabled: Boolean = false,
) {
companion object {
const val PREFIX: String = "query.logging"
}
} then the Interestingly, when I mark the data class as |
My test used a data class with a single constructor with a single property, it excludes #16293 The important difference from those is the APT for the configuration properties with the 'normal' class missed the defaultValue. |
Adding a |
After checking further, it seems that the the k2 compiler for some reason generates multiple constructors in the |
Although your Kolin class declares a single constructor, the generated bytecode has two. Here's the output from
I think that makes this one a duplicate of #16293 |
In the process of build a stream processor I discovered the recommended use of
@ConfigurationProperties
for kotlin doesn't work as expected.My test-processor repo. https://github.com/corneil/test-processor
When building the Java version a file is produced named
META-INF/spring-configuration-metadata.json
containing:The container image should have a label name
org.springframework.boot.spring-configuration-metadata.json
with all configuration properties and a label namedorg.springframework.cloud.dataflow.spring-configuration-metadata.json
with the configuration properties from classes named inMETA-INF/dataflow-configuration-metadata.properties
properties
section doesn't contain the propertycom.example.testprocessor2.addition
.defaultValue
is missing from the property in the case where properies are detected.Recommendation
Working version
Reproduce
The text was updated successfully, but these errors were encountered: