-
Notifications
You must be signed in to change notification settings - Fork 220
Description
STS for Eclipse Version: 4.21.0.RELEASE
In application config YAML files, STS will mark a property as unknown (error or warning depending on how I have STS configured) even if there is a setter for that property in the corresponding Java @ConfigurationProperties class. If I have both getter and setter, the error/warning goes away.
For example, given this class:
@ConfigurationProperties(prefix = "foo")
public class MyProperties {
private String envName;
public void setEnvName(String name) { };
}and this YAML:
foo:
envName: barSTS puts an error/warning marker in the YAML saying envName is an unknown property.
If I add this getter to MyProperties:
public String getEnvName() { return ""; }Then the YAML error/warning goes away.
It seems that a property with only a setter shouldn't trigger an error/warning, since all that matters to Spring is that it can know where to put the value from the YAML.
Before anyone starts quoting the Java Beans spec to me, I know that a property with no getter is not a strict Java Beans property. Practically speaking, however, Spring doesn't care; it still correctly sets the YAML value into the config object. So STS is not agreeing with Spring's own runtime behavior.