jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
694 stars 124 forks source link

ConfigurationProperties do not work in add-ons #3923

Open knstvk opened 15 hours ago

knstvk commented 15 hours ago

Environment

Jmix version: 2.4.1

Bug Description

After creating a @ConfigurationProperties class, the applications fails on start with the message:

Failed to bind properties under 'test.prop' to com.company.products.TestConfProperties:

    Reason: java.lang.IllegalStateException: Unable to create instance for com.company.products.TestConfProperties

This may be due to missing parameter name information

Action:

Update your application's configuration

Ensure that your compiler is configured to use the '-parameters' flag.
You may need to update both your build tool settings as well as your IDE.
(See https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#parameter-name-retention)

Steps To Reproduce

import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.bind.DefaultValue;

@ConfigurationProperties(prefix = "test.prop") public class TestConfProperties { String testProp;

public TestConfProperties(@DefaultValue("DEFAULT") String testProp) {
    this.testProp = testProp;
}

public String getTestProp() {
    return testProp;
}

}



- Start the application
knstvk commented 15 hours ago

Solution: add the following to the add-on's root build.gradle:

subprojects {
    // ...
    project.tasks.withType(JavaCompile).configureEach {
        options.compilerArgs.add("-parameters")
    }
}