WANG 6 年之前
父節點
當前提交
828cb33a39

+ 30 - 0
examcloud-exchange-starter/src/main/java/cn/com/qmth/examcloud/exchange/config/PropertiesConfig.java

@@ -0,0 +1,30 @@
+package cn.com.qmth.examcloud.exchange.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.event.ContextRefreshedEvent;
+
+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 ApplicationListener<ContextRefreshedEvent> {
+
+	@Value("${spring.profiles.active}")
+	private String springProfilesActive;
+
+	@Override
+	public void onApplicationEvent(ContextRefreshedEvent event) {
+		String resourceName = "application-" + springProfilesActive + ".properties";
+		PropertiesUtil.configureAndWatch(PathUtil.getResoucePath(resourceName));
+	}
+
+}