wangwei 7 yıl önce
ebeveyn
işleme
f6a6029dfb

+ 38 - 0
examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/core/basic/starter/config/PropertiesConfig.java

@@ -0,0 +1,38 @@
+package cn.com.qmth.examcloud.core.basic.starter.config;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.context.annotation.Configuration;
+
+import cn.com.qmth.examcloud.commons.base.util.PathUtil;
+import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
+
+/**
+ * 属性配置
+ *
+ * @author WANGWEI
+ * @date 2018年6月21日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+@Configuration
+public class PropertiesConfig implements BeanPostProcessor {
+
+	@Value("${spring.profiles.active}")
+	private String springProfilesActive;
+
+	@Override
+	public Object postProcessBeforeInitialization(Object bean, String beanName)
+			throws BeansException {
+		return bean;
+	}
+
+	@Override
+	public Object postProcessAfterInitialization(Object bean, String beanName)
+			throws BeansException {
+		String resourceName = "application-" + springProfilesActive + ".properties";
+		PropertiesUtil.configureAndWatch(PathUtil.getResoucePath(resourceName));
+		return bean;
+	}
+
+}