Sfoglia il codice sorgente

Merge branch 'master' of http://49.4.49.126:3000/GYEE_R.D/Gyee_Frame_NX

maxiaoxia 4 anni fa
parent
commit
5470e625c6

+ 45 - 0
src/main/java/com/gyee/frame/common/conf/monitor/LeaderConfig.java

@@ -0,0 +1,45 @@
+package com.gyee.frame.common.conf.monitor;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.annotation.PropertySources;
+import org.springframework.stereotype.Component;
+
+
+@Component
+@PropertySources({
+        @PropertySource("classpath:config/leader.properties"),
+})
+public class LeaderConfig {
+
+    @Value("${Leader.FDL}")
+    private String FDL;
+    @Value("${Leader.FS}")
+    private String FS;
+    @Value("${Leader.GL}")
+
+    private String GL;
+    public String getFDL() {
+        return FDL;
+    }
+
+    public void setFDL(String FDL) {
+        this.FDL = FDL;
+    }
+
+    public String getFS() {
+        return FS;
+    }
+
+    public void setFS(String FS) {
+        this.FS = FS;
+    }
+
+    public String getGL() {
+        return GL;
+    }
+
+    public void setGL(String GL) {
+        this.GL = GL;
+    }
+}

+ 45 - 0
src/main/java/com/gyee/frame/common/conf/monitor/StatusConfig.java

@@ -0,0 +1,45 @@
+package com.gyee.frame.common.conf.monitor;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.annotation.PropertySources;
+import org.springframework.stereotype.Component;
+
+
+@Component
+@PropertySources({
+        @PropertySource("classpath:config/status.properties"),
+})
+public class StatusConfig {
+
+    @Value("${Status.FDL}")
+    private String FDL;
+    @Value("${Status.FS}")
+    private String FS;
+    @Value("${Status.GL}")
+
+    private String GL;
+    public String getFDL() {
+        return FDL;
+    }
+
+    public void setFDL(String FDL) {
+        this.FDL = FDL;
+    }
+
+    public String getFS() {
+        return FS;
+    }
+
+    public void setFS(String FS) {
+        this.FS = FS;
+    }
+
+    public String getGL() {
+        return GL;
+    }
+
+    public void setGL(String GL) {
+        this.GL = GL;
+    }
+}

+ 3 - 0
src/main/resources/config/leader.properties

@@ -0,0 +1,3 @@
+Leader.FDL = FDL
+Leader.FS = FS
+Leader.GL =GL

+ 3 - 0
src/main/resources/config/status.properties

@@ -0,0 +1,3 @@
+Status.FDL = SCADAFDL
+Status.FS = SSFS
+Status.GL =PJGL

+ 33 - 0
src/test/java/test/ConfigTest.java

@@ -0,0 +1,33 @@
+package test;
+
+
+import com.gyee.SpringbootStart;
+import com.gyee.frame.common.conf.monitor.LeaderConfig;
+import com.gyee.frame.common.conf.monitor.StatusConfig;
+import com.gyee.frame.common.spring.SpringUtils;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+
+@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
+public class ConfigTest {
+
+    public static void main(String[] args) {
+
+        SpringApplication.run(SpringbootStart.class, args);
+
+        LeaderConfig leader = SpringUtils.getBean(LeaderConfig.class);
+
+        System.out.println(leader.getFDL());
+        System.out.println(leader.getFS());
+        System.out.println(leader.getGL());
+
+        StatusConfig status = SpringUtils.getBean(StatusConfig.class);
+
+        System.out.println(status.getFDL());
+        System.out.println(status.getFS());
+        System.out.println(status.getGL());
+    }
+
+
+}