Spring 是怎么管理properties文件的
来源:互联网 发布:收淘宝评价 编辑:程序博客网 时间:2024/05/16 08:52
Spring对properties文件的管理其实还是很容易的。
在app-config.xml里面声明一个class。
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:epublish-config.properties</value>
</list>
</property>
</bean>
这个类是Spring用来管理properties文件的。
properties文件就放在src下面的resource里。
我的properties里只有一行
authentication.control = FALSE
现在我想让我的一个java class的一个变量拿到这个properties文件里面的值
<bean id="service" class="Service">
<property name="authenticationController">
<value>${authentication.control}</value>
</property>
</bean>
在Service.java里
private String authenticationController;
public String getAuthenticationController() {
return authenticationController;
}
public void setAuthenticationController(String authenticationController) {
this.authenticationController = authenticationController;
}
由于我是要在子类ChildService里调用,
所以
<bean id="childService" class="ChildService" parent="service"/>
一定要告诉Spring,你这个child class的老爸是谁,才可以调用,否则,只有null了。
- Spring 是怎么管理properties文件的
- Spring怎么指定properties文件
- Spring的PropertyPlaceholderConfigurer应用与集成项目properties文件管理
- spring 管理xml以及properties文件
- 关于读取Properties文件的相对路径问题,怎么写是正确的?
- Spring 管理下的web项目,对Properties文件重要参数的加密解密处理
- Spring 管理下的web项目,对Properties文件重要参数的加密解密处理(续)
- Spring - 资源文件properties的配置
- Spring 资源文件 properties 的配置
- spring中属性文件properties的读取
- Spring - 资源文件properties的配置
- Spring - 资源文件properties的配置
- Spring - 资源文件properties的配置
- 加密Spring加载的Properties文件
- 加密Spring加载的Properties文件
- Spring如何获取Properties文件的信息
- Spring 加载 *.properties 文件的源码分析
- 唐僧是怎么管理孙悟空的?
- JavaScript js 操作cookies之增、删、查
- MySQL select into 和 SQLServer select into区别
- linux设置自启动程序
- 【C/C++语言入门篇】-- 剖析浮点数
- 使用Busybox制作根文件系统
- Spring 是怎么管理properties文件的
- Android屏幕密度(Density)和分辨率的解释
- Oracle数据库添加删除用户
- Oracle数据库管理及基础脚本
- 今天正式开博
- 【C/C++语言入门篇】-- 文件操作
- LINQ之使用Attach更新(Update with Attach)
- 人脸数据库汇总
- GIT中文教程