Spring 一二事(3) - 别名
Spring 别名 一二
2023-09-27 14:27:23 时间
别名就是可以通过另外一个名字来访问如下,已有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
相关文章
- Spring Boot 如何快速集成 Redis?
- Spring Boot 2.1.0 已发布,7 个重大更新!
- spring容器加载完毕做一件事情(利用ContextRefreshedEvent事件)
- Spring MVC Content Negotiation 转载
- Spring+Shiro搭建基于Redis的分布式权限系统(有实例)
- 使用spring jpa 时,利用nativeQuery,获取数据,无需新建实体,按照别名返回Json数据
- spring的AOP
- 【微服务~原始真解】Spring Cloud —— 配置绑定和配置属性校验
- Spring Boot2 系列教程(十三)Spring Boot 中的全局异常处理
- 创建一个 Spring Boot 项目,你会几种方法?
- cas 3.5.3服务器搭建+spring boot集成+shiro模拟登录(不修改现有shiro认证架构)