Spring中的@Value读取并注入配置信息
来源:互联网 发布:威迅java培训 编辑:程序博客网 时间:2024/06/06 00:42
@Value不仅可以读取配置文件中的信息 还可以使用SpEL进行运算操作
The first step
文件:musicer.properties内容:musicer.age=56musicer.song=my heart will go on
The second step
Spring文件内容<bean id="musicerProp" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <array> <value>classpath:musicer.properties</value> </array> </property></bean><bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"> <property name="properties" ref="musicerProp"/></bean>
The third step
@Value("#{musicerProp['musicer.age']}")private Integer age;@Value("#{musicerProp['musicer.song']}")private String song;
结果打印:
age: 56 Playing my heart will go on :
阅读全文
0 0
- Spring中的@Value读取并注入配置信息
- Spring如何读取properties中的配置信息
- 使用Spring读取xml文件中的配置信息
- spring boot @Value注解读取配置
- 手动读取spring配置信息
- spring @value无法注入
- spring @value 注入static
- spring基本配置,并自动注入
- Spring 配置读取config.properties配置信息
- Spring javaConfig编程式 配置properties属性@Value注入
- springMVC Controller 和 Service 通过@value 读取properties配置信息
- Spring MVC 通过@Value注解读取.properties配置
- Spring MVC 通过@Value注解读取.properties配置
- Spring MVC 通过@Value注解读取.properties配置
- Spring MVC 通过@Value注解读取.properties配置内容
- Spring MVC 通过@Value注解读取.properties配置内容
- Spring MVC 通过@Value注解读取.properties配置
- Spring中的注解配置-注入bean
- python numpy元素的区间查找
- Python tkinter多进程多线程前邮箱,再用pyinstaller编译成exe
- 使用LinqToExcel读取Excel
- 代码模拟手机与SIM卡的组合关系
- FragmentTabHost、Viewpager、Fragment使用过程中白屏问题及解决
- Spring中的@Value读取并注入配置信息
- IT的道德与伦理
- Android PopupWindow的简单使用
- Hoj 3269
- 希尔排序验证性实验
- LTE中RB和RE、REG、CCE的定义,和带宽的计算关系
- 用C语言实现矩阵边缘元素之和
- [BZOJ3881]-[Coci2015]Divljak-AC自动机+fail树+dfs序前缀和
- Java 线程状态