Merge branch '6.2.x'
# Conflicts: # framework-platform/framework-platform.gradle # spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java
This commit is contained in:
commit
096670f31d
|
@ -30,7 +30,7 @@ dependencies {
|
||||||
api("com.github.librepdf:openpdf:1.3.43")
|
api("com.github.librepdf:openpdf:1.3.43")
|
||||||
api("com.google.code.findbugs:findbugs:3.0.1")
|
api("com.google.code.findbugs:findbugs:3.0.1")
|
||||||
api("com.google.code.findbugs:jsr305:3.0.2")
|
api("com.google.code.findbugs:jsr305:3.0.2")
|
||||||
api("com.google.code.gson:gson:2.13.0")
|
api("com.google.code.gson:gson:2.13.1")
|
||||||
api("com.google.protobuf:protobuf-java-util:4.30.2")
|
api("com.google.protobuf:protobuf-java-util:4.30.2")
|
||||||
api("com.h2database:h2:2.3.232")
|
api("com.h2database:h2:2.3.232")
|
||||||
api("com.jayway.jsonpath:json-path:2.9.0")
|
api("com.jayway.jsonpath:json-path:2.9.0")
|
||||||
|
|
|
@ -131,6 +131,7 @@ final class ConfigurationClass {
|
||||||
* @param metadata the metadata for the underlying class to represent
|
* @param metadata the metadata for the underlying class to represent
|
||||||
* @param beanName name of the {@code @Configuration} class bean
|
* @param beanName name of the {@code @Configuration} class bean
|
||||||
* @param scanned whether the underlying class has been registered through a scan
|
* @param scanned whether the underlying class has been registered through a scan
|
||||||
|
* @since 6.2
|
||||||
*/
|
*/
|
||||||
ConfigurationClass(AnnotationMetadata metadata, String beanName, boolean scanned) {
|
ConfigurationClass(AnnotationMetadata metadata, String beanName, boolean scanned) {
|
||||||
Assert.notNull(beanName, "Bean name must not be null");
|
Assert.notNull(beanName, "Bean name must not be null");
|
||||||
|
|
|
@ -195,14 +195,14 @@ class ConfigurationClassBeanDefinitionReader {
|
||||||
AnnotationAttributes bean = AnnotationConfigUtils.attributesFor(metadata, Bean.class);
|
AnnotationAttributes bean = AnnotationConfigUtils.attributesFor(metadata, Bean.class);
|
||||||
Assert.state(bean != null, "No @Bean annotation attributes");
|
Assert.state(bean != null, "No @Bean annotation attributes");
|
||||||
|
|
||||||
// Consider name and any aliases
|
// Consider name and any aliases.
|
||||||
String[] explicitNames = bean.getStringArray("name");
|
String[] explicitNames = bean.getStringArray("name");
|
||||||
String beanName;
|
String beanName;
|
||||||
String localBeanName;
|
String localBeanName;
|
||||||
if (explicitNames.length > 0 && StringUtils.hasText(explicitNames[0])) {
|
if (explicitNames.length > 0 && StringUtils.hasText(explicitNames[0])) {
|
||||||
beanName = explicitNames[0];
|
beanName = explicitNames[0];
|
||||||
localBeanName = beanName;
|
localBeanName = beanName;
|
||||||
// Register aliases even when overridden below
|
// Register aliases even when overridden below.
|
||||||
for (int i = 1; i < explicitNames.length; i++) {
|
for (int i = 1; i < explicitNames.length; i++) {
|
||||||
this.registry.registerAlias(beanName, explicitNames[i]);
|
this.registry.registerAlias(beanName, explicitNames[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,7 @@ class ConfigurationBeanNameTests {
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||||
ctx.setBeanNameGenerator(new AnnotationBeanNameGenerator() {
|
ctx.setBeanNameGenerator(new AnnotationBeanNameGenerator() {
|
||||||
@Override
|
@Override
|
||||||
public String generateBeanName(
|
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
|
||||||
BeanDefinition definition, BeanDefinitionRegistry registry) {
|
|
||||||
return "custom-" + super.generateBeanName(definition, registry);
|
return "custom-" + super.generateBeanName(definition, registry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -78,17 +77,22 @@ class ConfigurationBeanNameTests {
|
||||||
ctx.close();
|
ctx.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Configuration("outer")
|
@Configuration("outer")
|
||||||
@Import(C.class)
|
@Import(C.class)
|
||||||
static class A {
|
static class A {
|
||||||
|
|
||||||
@Component("nested")
|
@Component("nested")
|
||||||
static class B {
|
static class B {
|
||||||
|
|
||||||
@Bean public String nestedBean() { return ""; }
|
@Bean public String nestedBean() { return ""; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Configuration("imported")
|
@Configuration("imported")
|
||||||
static class C {
|
static class C {
|
||||||
|
|
||||||
@Bean public String s() { return "s"; }
|
@Bean public String s() { return "s"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,4 +20,5 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ComponentForScanning {
|
public class ComponentForScanning {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,10 @@ import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class ConfigForScanning {
|
public class ConfigForScanning {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TestBean testBean() {
|
public TestBean testBean() {
|
||||||
return new TestBean();
|
return new TestBean();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue