@Controller
@RequestMapping("/value")
public class ValuePropertyController extends ApplicationController{ @Value("#{configProperties['jdbc.jdbcUrl']}")
private String jdbcUrl; @RequestMapping
public String value(){
System.out.println(jdbcUrl);
return "";
}
}

applicationContext.xml

<bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:database.properties</value>
</list>
</property>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
<property name="properties" ref="configProperties" />
</bean>

database.properties

jdbc.jdbcUrl=jdbc:mysql://localhost:3306/commentDemo?useUnicode=true&characterEncoding=UTF-8

通过@Value注解读取.properties配置内容的更多相关文章

  1. Spring MVC 通过@Value注解读取.properties配置内容

    第一步:在applicationContext.xml配置: <bean id="configProperties" class="org.springframew ...

  2. 五种方式让你在java中读取properties文件内容不再是难题

    一.背景 最近,在项目开发的过程中,遇到需要在properties文件中定义一些自定义的变量,以供java程序动态的读取,修改变量,不再需要修改代码的问题.就借此机会把Spring+SpringMVC ...

  3. Spring 如何读取properties文件内容

    http://hi.baidu.com/alizv/blog/item/d8cb2af4094662dbf3d38539.html 在现实工作中,我们常常需要保存一些系统配置信息,大家一般都会选择配置 ...

  4. 分别用Java和JS读取Properties文件内容

    项目中经常用到的配置文件,除了XML文件之外,还会用到Properties文件来存储一些信息,例如国际化的设置.jdbc连接信息的配置等.有时候也会把一些路径或者sql语句放到Properties中, ...

  5. @PropertySouce注解 读取 properties文件

    https://www.cnblogs.com/whx7762/p/7885735.html 1.@ProtertySource @PropertySouce是spring3.1开始引入的基于java ...

  6. spring boot --- 使用 注解 读取 properties 文件 信息

    1.前言 以前使用spring MVC框架 ,读取properties 配置文件需要写一大堆东西 ,也许 那时候 不怎么使用注解 ,现在使用spring boot ,发现了非常简便的办法---使用注解 ...

  7. spring使用@Value注解读取.properties文件时出现中文乱码问题的解决

    解决办法 在spring中我们常常使用.properties对一些属性进行一个提前配置, spring 在读取*.properties文件时, 默认使用的是asci码, 这时 我们需要对其编码进行转换 ...

  8. 读取.properties配置信息

    package com.ctcti.webcallcenter.utils; import java.io.FileInputStream;import java.io.FileNotFoundExc ...

  9. log4j.properties配置内容的理解

    一直知道log4j是用来记录日志的,但一直没去看log4j到底是怎么用的,这两天看了几个log4j.properties配置语句详解的帖子,在这里简陋地记录一下. 在完全不知道log4j怎么用的时候, ...

随机推荐

  1. Spring整合JDBC以及AOP管理事务

    本节内容: Spring整合JDBC Spring中的AOP管理事务 一.Spring整合JDBC Spring框架永远是一个容器,Spring整合JDBC其实就是Spring提供了一个对象,这个对象 ...

  2. apache camel 条件路由

    <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route id="e ...

  3. CCF CSP 201709-4 通信网络

    CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201709-4 通信网络 问题描述 某国的军队由N个部门组成,为了提高安全性,部门之间建立了M ...

  4. Oracle截取字符串和查找字符串

    oracle 截取字符(substr),检索字符位置(instr) case when then else end语句使用 收藏 常用函数:substr和instr 1.SUBSTR(string,s ...

  5. Android中selector背景选择器

    http://blog.csdn.net/forsta/article/details/26148403 http://blog.csdn.net/wswqiang/article/details/6 ...

  6. 快递鸟电子面单打印功能基于java

    之前的后天管理系统的电子面单打印使用的是灵通打单. 使用相对比较麻烦,需要到处Excel之后再导入,麻烦. 快递鸟有电子面单api,后台系统直接对接很是方便,不过也遇到了好些问题. 不难是不难,但是遇 ...

  7. .Net中的IO

    C#中的IO 本文环境为: Win 10 VS 2015 .net Framework 版本 4.0 File 类 File 类是一个工具类,可以用来判断文件是否存在和方便的创建文件, 读取.写入等操 ...

  8. 在chrome开发者工具中观察函数调用栈、作用域链、闭包

    在chrome的开发者工具中,通过断点调试,我们能够非常方便的一步一步的观察JavaScript的执行过程,直观感知函数调用栈,作用域链,变量对象,闭包,this等关键信息的变化.因此,断点调试对于快 ...

  9. Git 初学者使用指南及Git 资源整理

    Git 资源整理 Git is a free and open source distributed version control system designed to handle everyth ...

  10. (Nginx) URL REWRITE

    URL重写的基础介绍 把URI地址用作参数传递:URL REWRITE 最简单的是基于各种WEB服务器中的URL重写转向(Rewrite)模块的URL转换: 这样几乎可以不修改程序的实现将 news. ...