使用Spring 3的@value简化配置文件的读取
来源:互联网 发布:社交网络强弱关系 编辑:程序博客网 时间:2024/06/05 11:32
Spring 3支持@value注解的方式获取properties文件中的配置值,大简化了读取配置文件的代码。
1、在applicationContext.xml文件中配置properties文件
<bean id="appProperty" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <array> <value>classpath:app.properties</value> </array> </property></bean>
2、在bean中使用@value注解获取配置文件的值
@Value("${chengmi_crawl_timer_enable}")private Boolean timerEnabled;
即使给变量赋了初值也会以配置文件的值为准。
阅读全文
0 0
- 使用Spring 3的@value简化配置文件的读取
- 使用Spring 3的@value简化配置文件的读取
- 使用Spring 3的@value简化配置文件的读取
- Spring之@Value 注解获取properties值(Spring 3的@value简化配置文件的读取)
- 如何spring使用@value注解读取配置文件的值
- Spring boot 读取配置文件——@Value的使用
- 利用Spring的@Value注解读取配置文件
- spring3支持@value注解从配置文件中读取配置值,大大简化读取配置文件的代码@
- 使用import简化spring的配置文件
- 使用import简化spring的配置文件
- 使用import简化spring的配置文件
- 使用import简化spring的配置文件
- 使用import简化spring的配置文件
- 使用import简化spring的配置文件
- Spring 的配置文件简化与注解的使用
- 参数配置文件properties--使用spring加载和简化读取
- 读取和使用Spring的配置文件
- annotation 简化spring的配置文件bean
- 修改Windows默认窗口背景色为护眼色的方法
- 关于Xps9560 powershare(关机充电)问题
- springMVC中的@PathVariable
- org.apache.hadoop.mapreduce.task.reduce.Shuffle error in shuffle in fetcher
- IT 行业加班到底有没有价值?
- 使用Spring 3的@value简化配置文件的读取
- Android
- 算法总结——八皇后问题(三种解法)
- LINUX中错误 SELinux is disabled
- C++ 一个例子说明.c_str()函数
- linux中创建图片服务器减轻传统服务器的压力
- 学习Nginx之理解正向代理和反向代理
- USB描述符
- Android中 字符串、byte数组、十六进制串、ASCII之间的相互转化