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. 自动化 测试框架部署(python3+selenium2)

    安装Python 从https://www.python.org/downloads/下载最新版本的Python3,请注意,是3: 需要将Python的安装目录和安装目录下的Scripts文件夹添加到 ...

  2. java实现音频转换

    这里需要用到第三方 ffmpeg.exe package com.convertaudio; import java.io.File;import java.util.ArrayList;import ...

  3. java 基本数据类型 回顾

  4. 将EXE作为资源,然后在释放到磁盘上并运行该exe程序(使用了FindResource,LoadResource,然后用CFile写成一个文件)

    // 将exe作为资源加入,然后再释放出来,并运行 try { HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(IDR_EXE1), _T(" ...

  5. Find K most Frequent items in array

    给定一个String数组,求K个出现最频繁的数. 记录一下查到的资料和思路: 1. 使用heap sorting, 先用hashmap求出单词和词频.需要额外建立一个class Node,把单词和词频 ...

  6. Oracle Demo ->> CREATE TABLE

    Demo One CREATE TABLE employees_demo ( employee_id ) , first_name ) , last_name ) CONSTRAINT emp_las ...

  7. Elsevier 投稿各种状态总结

    Elsevier 投稿各种状态总结1. Submitted to Journal      当上传结束后,显示的状态是Submitted to Journal,这个状态是自然形成的无需处理.2. Wi ...

  8. sed文本处理知识点整理

    参考资料:http://man.linuxde.net/sed    <鸟哥的私房菜> sed是一种流编辑器,它是文本处理中非常中的工具,能够完美的配合正则表达式使用.sed 后面接的操作 ...

  9. Zend13.0 +XAMPP3.2.2 调试配置

    Zend 调试PHP有3种方式: (1)PHP CLI APPLICATION (2)PHP Web Application (3)PHP UnitTest (1).(2)两种方式配置相似,下图是配置 ...

  10. Java —— 时区(夏令时)问题

    有没有遇到过这样的情况:数据库里的是时间是“1991-4-14”,但是Java取出来后就成了“1991-4-13”. 解决方法一: 先把时区设成GMT,把 根据夏时制自动调节时钟 的选项去掉. 再把时 ...