使用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 ...
随机推荐
- Html网页的代码
Html网页的代码 很全哦 1)贴图:<img src="图片地址"> 2)加入连接:<a href="所要连接的相关地址">写上你想写 ...
- Java IO 过滤流 BufferedInput/OutputStream
Java IO 过滤流 BufferedInput/OutputStream @author ixenos 概念 BufferedInput/OutputStream是实现缓存的过滤流,他们分别是Fi ...
- 浙大pat 1025题解
1025. PAT Ranking (25) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...
- webpack 相关资料
github webpack Youtube: Advanced Webpack code splitting list of plugins webpack examples What's new ...
- git三个区域详解
一.可以将git简单的分为三个区域 1.工作区(working directory) 2.暂缓区(stage index) 3.历史记录区(history) 二.三个区域关系:工作区 ...
- boost 编译依赖库
正则表达式 icu-devel python python-devel bzip2-devel ./b2 variant=release link=shared threading=multi run ...
- Openjudge-计算概论(A)-整数的个数
描述: 给定k(1<k<100)个正整数,其中每个数都是大于等于1,小于等于10的数.写程序计算给定的k个正整数中,1,5和10出现的次数.输入输入有两行:第一行包含一个正整数k,第二行包 ...
- jsp页面中EL表达式不能被解析
原因是:在默认情况下,Servlet 2.4 / JSP 2.0支持 EL 表达式. 用maven插件的生成的webApp的项目结构比较老的是2.3的版本,只要将web中的开头定义换成2.4以上的定义 ...
- Smarty 注册变量
关于smarty类的一些解析 特别注意左右分隔符<{}>,display------显示模板的内容(里面是.html文件),assign-------注册变量 <?php //是一个 ...
- go pkg
fmt Scanln用来读取输入数据 示例: package main import ( "fmt" "os" "time" ) func ...