Skip to content
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

@Name support for value object binding fails with Kotlin classes #24379

Closed
agebhar1 opened this issue Dec 7, 2020 · 0 comments
Closed

@Name support for value object binding fails with Kotlin classes #24379

agebhar1 opened this issue Dec 7, 2020 · 0 comments
Assignees
Milestone

Comments

@agebhar1
Copy link
Contributor

@agebhar1 agebhar1 commented Dec 7, 2020

Spring Boot 2.4.0 added custom property name support for constructor binding on configuration property classes. The release notes mention a Java example. I guess it should also work for Kotlin data classes.

Java:

@ConfigurationProperties("application")
@ConstructorBinding
public class MyConfig {

    private final String importValue;

    public MyConfig(@Name("import") final String importValue) {
        this.importValue = importValue;
    }

    public String getImport() {
        return importValue;
    }
}

Kotlin:

@ConfigurationProperties("application")
@ConstructorBinding
data class MyConfig(@Name("import") val importValue: String)

application.yml:

application:
  import: any

The test is successful for Java but fails for Kotlin. Here is a minimal example.

@philwebb philwebb added this to the 2.4.x milestone Dec 7, 2020
@scottfrederick scottfrederick self-assigned this Dec 7, 2020
@scottfrederick scottfrederick changed the title custom property name support in Kotlin fails @Name support for value object binding fails with Kotlin classes Dec 8, 2020
@scottfrederick scottfrederick modified the milestones: 2.4.x, 2.4.1 Dec 8, 2020
philwebb added a commit that referenced this issue Dec 10, 2020
Update `ValueObjectBinder` Kotlin support to meta-annotations of
`@Named`.

See gh-24379
agebhar1 added a commit to agebhar1/spring-boot-config-custom-property-name that referenced this issue Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants