Merge branch '3.3.x' into 3.4.x
Closes gh-45651
This commit is contained in:
@@ -59,6 +59,7 @@ import org.springframework.util.ResourceUtils;
|
||||
* @author Scott Frederick
|
||||
* @author Ivan Malutin
|
||||
* @author Phillip Webb
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
final class ArchitectureRules {
|
||||
|
||||
@@ -88,6 +89,7 @@ final class ArchitectureRules {
|
||||
rules.add(noClassesShouldCallStringToLowerCaseWithoutLocale());
|
||||
rules.add(conditionalOnMissingBeanShouldNotSpecifyOnlyATypeThatIsTheSameAsMethodReturnType());
|
||||
rules.add(enumSourceShouldNotSpecifyOnlyATypeThatIsTheSameAsMethodParameterType());
|
||||
rules.add(allConfigurationPropertiesBindingBeanMethodsShouldBeStatic());
|
||||
return List.copyOf(rules);
|
||||
}
|
||||
|
||||
@@ -244,6 +246,14 @@ final class ArchitectureRules {
|
||||
}
|
||||
}
|
||||
|
||||
private static ArchRule allConfigurationPropertiesBindingBeanMethodsShouldBeStatic() {
|
||||
return methodsThatAreAnnotatedWith("org.springframework.context.annotation.Bean").and()
|
||||
.areAnnotatedWith("org.springframework.boot.context.properties.ConfigurationPropertiesBinding")
|
||||
.should()
|
||||
.beStatic()
|
||||
.allowEmptyShould(true);
|
||||
}
|
||||
|
||||
private static boolean containsOnlySingleType(JavaType[] types, JavaType type) {
|
||||
return types.length == 1 && type.equals(types[0]);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class FlywayAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
public StringOrNumberToMigrationVersionConverter stringOrNumberMigrationVersionConverter() {
|
||||
public static StringOrNumberToMigrationVersionConverter stringOrNumberMigrationVersionConverter() {
|
||||
return new StringOrNumberToMigrationVersionConverter();
|
||||
}
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ class SecurityAutoConfigurationTests {
|
||||
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
Converter<String, TargetType> targetTypeConverter() {
|
||||
static Converter<String, TargetType> targetTypeConverter() {
|
||||
return new Converter<>() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1593,7 +1593,7 @@ class ConfigurationPropertiesTests {
|
||||
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
Converter<String, Person> personConverter() {
|
||||
static Converter<String, Person> personConverter() {
|
||||
return new PersonConverter();
|
||||
}
|
||||
|
||||
@@ -1604,7 +1604,7 @@ class ConfigurationPropertiesTests {
|
||||
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
Converter<String, Alien> alienConverter() {
|
||||
static Converter<String, Alien> alienConverter() {
|
||||
return new AlienConverter();
|
||||
}
|
||||
|
||||
@@ -1625,7 +1625,7 @@ class ConfigurationPropertiesTests {
|
||||
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
GenericConverter genericPersonConverter() {
|
||||
static GenericConverter genericPersonConverter() {
|
||||
return new GenericPersonConverter();
|
||||
}
|
||||
|
||||
@@ -1636,7 +1636,7 @@ class ConfigurationPropertiesTests {
|
||||
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
Formatter<Person> personFormatter() {
|
||||
static Formatter<Person> personFormatter() {
|
||||
return new PersonFormatter();
|
||||
}
|
||||
|
||||
@@ -3064,7 +3064,7 @@ class ConfigurationPropertiesTests {
|
||||
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
WithObjectToObjectMethodConverter withObjectToObjectMethodConverter() {
|
||||
static WithObjectToObjectMethodConverter withObjectToObjectMethodConverter() {
|
||||
return new WithObjectToObjectMethodConverter();
|
||||
}
|
||||
|
||||
|
||||
@@ -102,13 +102,13 @@ class ConversionServiceDeducerTests {
|
||||
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
TestConverter testConverter() {
|
||||
static TestConverter testConverter() {
|
||||
return new TestConverter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationPropertiesBinding
|
||||
StringConverter stringConverter() {
|
||||
static StringConverter stringConverter() {
|
||||
return new StringConverter();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user