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;
自定义配置文件内容:
#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 boot 添加自定义配置文件并读取属性
- Springboot 之 自定义配置文件及读取配置文件
- Springboot 之 自定义配置文件及读取配置文件注意:配置文件中的字符串不要有下划线 .配置中 key不能带下划线,value可以(下划线的坑,坑了我两天..特此纪念)
- Spring boot之读取自定义配置文件
- Springboot 读取配置文件及自定义配置文件
- Spring自定义配置文件读取类
- Springboot读取配置文件及自定义配置文件的方法
- springBoot使用Controller读取配置文件两种方式&读取自定义配置方法
- Springboot 之 自定义配置文件及读取配置文件
- Springboot 之 自定义配置文件及读取配置文件
- Spring-boot中读取核心配置文件application和自定义properties配置文件的方式
- Springboot 之 自定义配置文件及读取配置文件
- 自定义spring容器--spring容器读取bean配置文件的原理
- Springboot 之 自定义配置文件及读取配置文件
- SpringBoot自定义配置文件读取
- Springboot 之 自定义配置文件及读取配置文件
- [spring源码学习]三、IOC源码——自定义配置文件读取
- Spring读取自定义properties配置文件
- 五、Springboot 之 自定义配置文件及读取配置文件
- dom4j实现模拟Spring读取配置文件 注入