Sfoglia il codice sorgente

增加配置文件读取

tags/v1.0.0^2
林万龙 3 anni fa
parent
commit
c3d71e8da5
2 ha cambiato i file con 19 aggiunte e 1 eliminazioni
  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 Vedi File

@@ -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 Vedi File

@@ -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();
}
}

Loading…
Annulla
Salva