别名就是可以通过另外一个名字来访问如下,已有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

相关文章:

  • 2021-11-30
  • 2021-07-13
  • 2021-11-01
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
猜你喜欢
  • 2021-06-25
  • 2021-11-24
  • 2021-06-07
  • 2022-01-25
  • 2022-12-23
  • 2021-07-19
相关资源
相似解决方案