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简化配置文件的读取的更多相关文章

  1. 使用Spring 3的@value简化配置文件的读取 (转)

    Spring 3支持@value注解的方式获取properties文件中的配置值,大简化了读取配置文件的代码. 1.在applicationContext.xml文件中配置properties文件 & ...

  2. 【Spring】13、使用Spring 3的@value简化配置文件的读取

    Spring 3支持@value注解的方式获取properties文件中的配置值,大简化了读取配置文件的代码. 1.在applicationContext.xml文件中配置properties文件 & ...

  3. spring中使用 @value 简化配置文件的读取

    1.在applicationContext.xml文件中配置properties文件 <bean id="propertyConfigurer" class="or ...

  4. spring加载多个配置文件

    首先我们都知道要使用spring,则需要在web.xml中增加如下代码: web.xml: 1:<listener><listener-class>org.springfram ...

  5. Spring中加载xml配置文件的六种方式

    Spring中加载xml配置文件的六种方式 博客分类: Spring&EJB XMLSpringWebBeanBlog  因为目前正在从事一个项目,项目中一个需求就是所有的功能都是插件的形式装 ...

  6. Spring配置文件的读取

    1.配置文件的命名 Spring框架中的默认配置文件,建议命名为applicationContext.xml * 编写配置文件,默认位置有两个 ①src目录.②WEB-INF目录 2.Spring 配 ...

  7. spring+hibernate+jpa+Druid的配置文件,spring整合Druid

    spring+hibernate+jpa+Druid的配置文件 spring+hibernate+jpa+Druid的完整配置 spring+hibernate+jpa+Druid的数据源配置 spr ...

  8. spring 对jdbc的简化

    spring.xml <!-- 加载属性配置文件 --> <util:properties id="db" location="classpath:db ...

  9. Spring注解使用和与配置文件的关系

      Spring注解使用和与配置文件的关系 1 注解概述与容器管理机制 Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repositor ...

随机推荐

  1. mq_notify

    NAME mq_notify - 通知进程可以接收一条消息 (REALTIME) SYNOPSIS #include <mqueue.h> int mq_notify(mqd_t mqde ...

  2. 【golang】用container/list实现栈(Stack)

    go语言中的container有heap.list.ring,没有stack. 其中heap是优先级队列,虽然有Push()/Pop()接口,但是使用heap要实现heap.Interface接口,不 ...

  3. iOS NSPredicate和正则表达式

    简述:Cocoa 提供了NSPredicate 用于指定过滤条件,谓词是指在计算机中表示计算真假值的函数,它使用起来有点儿像SQL 的查询条件,主要用于从集合中分拣出符合条件的对象,也可以用于字符串的 ...

  4. IDEA中利用JUnit进行单元测试

    打开IntelliJ IDEA工具,Alt+Ctrl+S,打开设置窗口,点击进入Plugins. 从插件资源库中搜索JunitGenerator V2.0版本

  5. 273. Integer to English Words

    题目: Convert a non-negative integer to its english words representation. Given input is guaranteed to ...

  6. istream, outstream使用及常见错误

    使用方法: 使用filebuf打开文件,并拷贝给istream/ostream. 如下面的例子中,实现读取并处理deseq文件夹下所有文件,输出到ostream fw. code: #include& ...

  7. SPA与DPA 攻击【转】

    转自:http://blog.sina.com.cn/s/blog_6cb58dbf0102v7ym.html SPA SPA是一种直接解释能量消耗测定值的技术.系统消耗能量的大小随微处理器执行的指令 ...

  8. 《c程序设计语言》读书笔记--大写转小写

    #include <stdio.h> #include <stdlib.h> #include <string.h> int aoti(char c) { if(c ...

  9. Hibernate 中update hql语句

    今天在MySQL中用hibernate测试update语句发现以下问题: update语句竟然不去作用: 表机构如下: create table student(sid int primary key ...

  10. MSAA, UIA brief explanation

    MSAA, UIA brief explanation 2014-07-24 Reference [1] MSAA, UIA brief explanation [2] Testing Tools [ ...