使用Spring 3的@value简化配置文件的读取 (转)
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;
即使给变量赋了初值也会以配置文件的值为准。
使用Spring 3的@value简化配置文件的读取 (转)的更多相关文章
- 使用Spring 3的@value简化配置文件的读取
Spring 3支持@value注解的方式获取properties文件中的配置值,大简化了读取配置文件的代码. 1.在applicationContext.xml文件中配置properties文件 & ...
- 【Spring】13、使用Spring 3的@value简化配置文件的读取
Spring 3支持@value注解的方式获取properties文件中的配置值,大简化了读取配置文件的代码. 1.在applicationContext.xml文件中配置properties文件 & ...
- spring中使用 @value 简化配置文件的读取
1.在applicationContext.xml文件中配置properties文件 <bean id="propertyConfigurer" class="or ...
- spring加载多个配置文件
首先我们都知道要使用spring,则需要在web.xml中增加如下代码: web.xml: 1:<listener><listener-class>org.springfram ...
- Spring中加载xml配置文件的六种方式
Spring中加载xml配置文件的六种方式 博客分类: Spring&EJB XMLSpringWebBeanBlog 因为目前正在从事一个项目,项目中一个需求就是所有的功能都是插件的形式装 ...
- Spring配置文件的读取
1.配置文件的命名 Spring框架中的默认配置文件,建议命名为applicationContext.xml * 编写配置文件,默认位置有两个 ①src目录.②WEB-INF目录 2.Spring 配 ...
- spring+hibernate+jpa+Druid的配置文件,spring整合Druid
spring+hibernate+jpa+Druid的配置文件 spring+hibernate+jpa+Druid的完整配置 spring+hibernate+jpa+Druid的数据源配置 spr ...
- spring 对jdbc的简化
spring.xml <!-- 加载属性配置文件 --> <util:properties id="db" location="classpath:db ...
- Spring注解使用和与配置文件的关系
Spring注解使用和与配置文件的关系 1 注解概述与容器管理机制 Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repositor ...
随机推荐
- Chapter 2 Open Book——29
Which left me with nothing to do but try to not look at him…unsuccessfully. 我没什么事情可以做但是我尝试不去看他,但是失败了 ...
- WOT2016大数据技术峰会——千人技术盛宴
WOT2016大数据技术峰会是一场聚焦大数据领域最前沿的的技术及经验分享.2016年11月25-26日北京粤财JW万豪酒店如约而至,会议规模达到1000人! 由51CTO主办的千人技术盛宴--WOT2 ...
- 《JS权威指南学习总结--8.8.3 不完全函数》
内容要点: 本节讨论的是一种函数变换技巧,即把一次完整的函数调用拆成多次函数调用,每次传入的实参都是完整实参的一部分,每个拆分开的函数叫做不完全函数(partial function),每次函数调用叫 ...
- Flask-Request对象属性
Request属性 元属性 method host path environ headers data body中的内容 最安全 解析后 remote_addr args form values a ...
- jquery设置select选中
/*设置select选中开始*/ var prod_type=$('.prod_type').val(); //alert(prod_type); var select = document.getE ...
- 把json数据 [ { } ] 转为数组
$str = '[{"rwx_price":388.5,"end_station_name":"长沙","swz_price&qu ...
- Java面向对象总复习-QuickHit
1.创建玩家级别类Level.java package com.bdqn; /** * 1.玩家级别类 * @author pc * */ public class Level { /** * 级别号 ...
- osgOcean测试
#include <osgViewer/Viewer> #include <osgDB/ReadFile> #include <osgGA/TrackballManipu ...
- [ An Ac a Day ^_^ ] hdu 5835 Danganronpa 令人发指
这道题告诉我两个道理: 1.记得写case 要不挂死你 2.数据很水的时候 只有样例的这一种情况…… 原来数据可以这么水…… #include<stdio.h> #include<i ...
- table边框1px
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...