Spring中加载属性文件
来源:互联网 发布:php 闭包 参数 编辑:程序博客网 时间:2024/05/01 02:32
在xml文件中加入:
<util:properties id="userProperties" location="classpath:user.properties"/>
头部加入:
xmlns:util=http://www.springframework.org/schema/util
在xsi:schemaLocation中加入:
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
加它的位置,要跟定义用到它的那个类的bean在同一个上下文里。比如我在app-root里有个component-scan,所以就加在了app-root里。
然后对于用到它的类(如果之前不是bean的话要加@Component)里面加上:
@Resource(name = "userProperties")
private Properties userProperties;
就可以在方法里直接用了。
0 0
- Spring中加载属性文件
- Spring中加载属性文件
- 将属性文件加载道spring容器中
- spring加载java属性文件
- spring的属性加载器,加载properties文件中的属性
- Spring 中加载资源文件
- Spring 中加载资源文件
- Spring 中加载资源文件
- spring中加载properties文件
- Spring中外部属性文件
- spring+mybatis 注入properties文件中属性失败导致datasource加载失败的原因和解决
- 加载spring信息,属性文件信息,注册proxool
- spring配置文件加载FTP服务器上的属性文件
- 关于spring没有加载属性文件的问题
- Spring-----多环境中加载资源配置文件
- Spring配置中引用外部属性文件
- spring中属性文件properties的读取
- Spring 中如何使用外部属性文件
- hdu1067 Gap (bfs+hash)
- Nutch1.8+Hadoop1.2+Solr4.3分布式集群配置
- 珠宝软件信息化之道
- linux 服务器之间拷贝文件
- 手动实现openstack vlan 二层网络结构
- Spring中加载属性文件
- 软件性能测试的本质
- 互联网协议入门(二)
- 【android】深入动画系列
- 印度互联网创业大热:会出现“下一个苹果”?
- 设备树使用手册
- Instagram删除上千万虚假帐户 掉粉用户怒了
- leetcode 一句话算法
- jaxb的优点和用法