Spring 一二事(3)

别名就是可以通过另外一个名字来访问如下,已有bean:helloWorld3,那么定义别名(alias )后,就能使用“abc”来访问

1    <bean id="helloWorld3" factory-bean="helloWorldFactory"
2         factory-method="getInstance"></bean>
3 
4     <!-- 别名 name 属性值要和 id 一致 -->
5     <alias name="helloWorld3" alias="abc" />
6     <alias name="helloWorld3" alias="测试" />
HelloWorld hello = (HelloWorld)context.getBean("abc");

 github地址:https://github.com/leechenxiang/maven-spring001-helloworld

原文地址:https://www.cnblogs.com/leechenxiang/p/5305317.html