码迷,mamicode.com
首页 > 编程语言 > 详细

spring boot 使用 EnvironmentAware 加载配置文件

时间:2018-07-17 18:10:57      阅读:2202      评论:0      收藏:0      [点我收藏+]

标签:over   文件头   nta   java   配置   setenv   void   red   private   

@Configuration
public class PropertiesUtils implements EnvironmentAware {

	private int redisExpireTime;
	
	private boolean enabled;
	
	private int refreshTime;

	@Override
	public void setEnvironment(Environment environment) {
          //解析配置文件头 RelaxedPropertyResolver relaxedPropertyResolver = new RelaxedPropertyResolver(environment, "custom."); this.redisExpireTime=Integer.valueOf(relaxedPropertyResolver.getProperty("redisExpireTime")); this.enabled=Boolean.valueOf(relaxedPropertyResolver.getProperty("enabled")); this.refreshTime=Integer.valueOf(relaxedPropertyResolver.getProperty("refreshTime")); }

  

spring boot 使用 EnvironmentAware 加载配置文件

标签:over   文件头   nta   java   配置   setenv   void   red   private   

原文地址:https://www.cnblogs.com/itniwota/p/9324312.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!