Merge branch '2.0.x'

This commit is contained in:
Stephane Nicoll 2018-05-02 16:08:03 +02:00
commit 4eeddbd889
4 changed files with 65 additions and 0 deletions

View File

@ -1209,6 +1209,13 @@
"level": "error"
}
},
{
"name": "spring.flyway.locations",
"type": "java.util.List<java.lang.String>",
"defaultValue": [
"classpath:db/migration"
]
},
{
"name": "spring.flyway.sql-migration-suffix",
"deprecation": {

View File

@ -150,6 +150,10 @@ public class ConfigurationMetadata {
return null;
}
candidates.removeIf((itemMetadata) -> !itemMetadata.hasSameType(metadata));
if (candidates.size() > 1 && metadata.getType() != null) {
candidates.removeIf((itemMetadata) ->
!metadata.getType().equals(itemMetadata.getType()));
}
if (candidates.size() == 1) {
return candidates.get(0);
}

View File

@ -80,6 +80,7 @@ import org.springframework.boot.configurationsample.specific.InnerClassPropertie
import org.springframework.boot.configurationsample.specific.InnerClassRootConfig;
import org.springframework.boot.configurationsample.specific.InvalidAccessorProperties;
import org.springframework.boot.configurationsample.specific.InvalidDoubleRegistrationProperties;
import org.springframework.boot.configurationsample.specific.SimpleConflictingProperties;
import org.springframework.boot.configurationsample.specific.SimplePojo;
import org.springframework.boot.configurationsample.specific.StaticAccessor;
import org.springframework.boot.configurationsample.specific.WildcardConfig;
@ -758,6 +759,19 @@ public class ConfigurationMetadataAnnotationProcessorTests {
assertThat(metadata.getItems()).hasSize(4);
}
@Test
public void mergeExistingPropertyWithSeveralCandidates() throws Exception {
ItemMetadata property = ItemMetadata.newProperty("simple", "flag",
Boolean.class.getName(), null, null, null, true, null);
writeAdditionalMetadata(property);
ConfigurationMetadata metadata = compile(SimpleProperties.class,
SimpleConflictingProperties.class);
assertThat(metadata.getItems()).hasSize(6);
assertThat(metadata).has(Metadata.withProperty("simple.flag", Boolean.class)
.fromSource(SimpleProperties.class).withDescription("A simple flag.")
.withDeprecation(null, null).withDefaultValue(true));
}
@Test
public void mergeExistingPropertyDescription() throws Exception {
ItemMetadata property = ItemMetadata.newProperty("simple", "comparator", null,

View File

@ -0,0 +1,40 @@
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.configurationsample.specific;
import org.springframework.boot.configurationsample.ConfigurationProperties;
import org.springframework.boot.configurationsample.simple.SimpleProperties;
/**
* Properties that conflict with {@link SimpleProperties}.
*
* @author Stephane Nicoll
*/
@ConfigurationProperties("simple")
public class SimpleConflictingProperties {
private String flag = "hello";
public String getFlag() {
return this.flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
}