您的位置:首页 > 编程语言 > Java开发

spring 读取自定义配置文件

2016-09-24 22:50 183 查看
自定义的配置文件,可以很简单的用spring读出来。

自定义配置文件内容:

#project self setting
debug_mode=true

version_type=cgq

spring 配置:
<!-- 加载自定义配置文件 -->
<bean id="myPropertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/WEB-INF/classes/conf/self.properties</value>
</property>
<property name="fileEncoding" value="utf-8" />
</bean>

代码中使用:
import org.springframework.beans.factory.annotation.Value;

@Value("${version_type}")
private String version_type;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring