Allow registering aliases with BeanRegistry

Closes gh-34599
This commit is contained in:
Sébastien Deleuze
2025-03-19 15:07:54 +01:00
parent 087d239148
commit 2bc213d703
6 changed files with 30 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ class BeanRegistrarDslConfigurationTests {
fun beanRegistrar() {
val context = AnnotationConfigApplicationContext(BeanRegistrarKotlinConfiguration::class.java)
assertThat(context.getBean<Bar>().foo).isEqualTo(context.getBean<Foo>())
assertThat(context.getBean<Foo>("foo")).isEqualTo(context.getBean<Foo>("fooAlias"))
assertThatThrownBy(ThrowableAssert.ThrowingCallable { context.getBean<Baz>() }).isInstanceOf(NoSuchBeanDefinitionException::class.java)
assertThat(context.getBean<Init>().initialized).isTrue()
val beanDefinition = context.getBeanDefinition("bar")
@@ -88,7 +89,8 @@ class BeanRegistrarDslConfigurationTests {
internal class BeanRegistrarKotlinConfiguration
private class SampleBeanRegistrar : BeanRegistrarDsl({
registerBean<Foo>()
registerBean<Foo>("foo")
registerAlias("foo", "fooAlias")
registerBean(
name = "bar",
prototype = true,