-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Consistent configuration property binding for nested classes on JVM and native-image #31708
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
Comments
It seems that there are hints missing for the |
This feels like something we overlooked in #30916. As it has already shipped, I think we should handle this as a bug as it's something that we expected to work now but does not. |
Possibly related issue: For the following configuration:
that should be binded to this bean when I package with AOT and run via
|
It's important that the getters and setters are |
After a discussion with the team, i decided to revert my commit and reopen the issue. @OlgaMaciaszek: You can generate hints by annotating the field which points to a non-inner class which should be bound with The current algorithm works as follows:
We're coming up in the future with a better way to handle that, but we have to do some design work first. |
Nonetheless I think there is a bug in our implementation: Map<String, List<SomeType>> getMap(); won't lead to the class |
We now generate hints correctly for nested generics. |
I've summarized the problems and possible ways forward in this document. |
We're going to keep things as they are and expect users to add |
Interesting. I just tested it again, and some change we did made the This class binds without problems in a native image: @ConfigurationProperties(prefix = "my.properties")
class MyProperties {
private String name;
private final Nested nested = new Nested();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Nested getNested() {
return nested;
}
public static class Nested {
private int number;
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
}
} The getters/setters still have to be public, though. |
Uh oh!
There was an error while loading. Please reload this page.
While working on the AOT smoke test
configuration-properties
I encountered a case where binding a nested class fails in native image. This works in JVM mode.See the failing build here: https://ci.spring.io/teams/spring-aot-smoke-tests/pipelines/spring-aot-smoke-tests-1.0.x/jobs/configuration-properties
The text was updated successfully, but these errors were encountered: