Quellcode durchsuchen

增加配置文件读取

tags/v1.0.0^2
林万龙 vor 3 Jahren
Ursprung
Commit
c3d71e8da5
2 geänderte Dateien mit 19 neuen und 1 gelöschten Zeilen
  1. +18
    -0
      src/main/java/com/telpo/dipperposition/config/PositionConfig.java
  2. +1
    -1
      src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java

+ 18
- 0
src/main/java/com/telpo/dipperposition/config/PositionConfig.java Datei anzeigen

@@ -29,5 +29,23 @@ import java.util.Properties;
@Configuration
@ConfigurationProperties(prefix = "position")
public class PositionConfig {
@Value("${position.hello}")
private String hello;

PositionConfig()
{
}

private static PositionConfig instance;
public static PositionConfig getInstance(){
if (instance==null){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
instance = new PositionConfig();
}
return instance;
}
}

+ 1
- 1
src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java Datei anzeigen

@@ -44,7 +44,7 @@ public class DipperPositionController {
// //log.info(positionId + ":" + content.positionId)
// Map<String, Object> dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml");
// return dataMap == null ? "" : (String)dataMap.get(positionId);
return RzlAccount.getInstance().getHello();
return PositionConfig.getInstance().getHello();
//return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
}

Laden…
Abbrechen
Speichern