-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Closed
Description
Starting with 2.2.0.M3 spring-boot-configuration-processor generates an incorrect spring-configuration-metadata.json when configuration property class contains another autowired ConfigurationProperties.
@Autowired
public BrokenConfigProperties(@Autowired(required = false) NestedConfigProperties nested) {
this.nested = nested;
}This works in 2.1.5.RELEASE and 2.2.0.M1.
Full example: https://github.com/bdemers/spring-config-problem
Running this example with M2 or M3 creates metadata:
{
"groups": [
{
"name": "another.namespace",
"type": "com.example.spring.configproblem.NestedConfigProperties",
"sourceType": "com.example.spring.configproblem.NestedConfigProperties"
},
{
"name": "example.broken",
"type": "com.example.spring.configproblem.BrokenConfigProperties",
"sourceType": "com.example.spring.configproblem.BrokenConfigProperties"
}
],
"properties": [
{
"name": "another.namespace.other-property",
"type": "java.lang.String",
"sourceType": "com.example.spring.configproblem.NestedConfigProperties"
},
{
"name": "example.broken.nested",
"type": "com.example.spring.configproblem.NestedConfigProperties",
"sourceType": "com.example.spring.configproblem.BrokenConfigProperties"
}
],
"hints": []
}expected (and 2.1.5.RELEASE output):
{
"groups": [
{
"name": "another.namespace",
"type": "com.example.spring.configproblem.NestedConfigProperties",
"sourceType": "com.example.spring.configproblem.NestedConfigProperties"
},
{
"name": "example.broken",
"type": "com.example.spring.configproblem.BrokenConfigProperties",
"sourceType": "com.example.spring.configproblem.BrokenConfigProperties"
}
],
"properties": [
{
"name": "another.namespace.other-property",
"type": "java.lang.String",
"sourceType": "com.example.spring.configproblem.NestedConfigProperties"
},
{
"name": "example.broken.a-string-value",
"type": "java.lang.String",
"sourceType": "com.example.spring.configproblem.BrokenConfigProperties"
}
],
"hints": []
}In this case the property a-string-value is missing from the M3 version.
A work around (not fully tested), is to add a default constructor the the config properties object:
private BrokenConfigProperties() {
this(null);
}
@Autowired
public BrokenConfigProperties(@Autowired(required = false) NestedConfigProperties nested) {
this.nested = nested;
}Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug