Kaynağa Gözat

增加配置文件读取

tags/v1.0.0^2
林万龙 3 yıl önce
ebeveyn
işleme
f4273be990
2 değiştirilmiş dosya ile 12 ekleme ve 11 silme
  1. +1
    -1
      src/main/java/com/telpo/dipperposition/config/PositionConfig.java
  2. +11
    -10
      src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java

+ 1
- 1
src/main/java/com/telpo/dipperposition/config/PositionConfig.java Dosyayı Görüntüle

@@ -20,7 +20,7 @@ import org.springframework.context.annotation.Configuration;
@ConfigurationProperties(prefix = "position")
public class PositionConfig {

//@Value("${hello}")
@Value("${hello}")
private String hello;

}

+ 11
- 10
src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java Dosyayı Görüntüle

@@ -32,7 +32,7 @@ public class DipperPositionController {
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
ConfigService configService = NacosFactory.createConfigService(properties);
String content = configService.getConfig(dataId, group, 5000);
String content = configService.getConfig(dataId, group, 10000);
System.out.println(content);
configService.addListener(dataId, group, new Listener() {
@Override
@@ -50,21 +50,22 @@ public class DipperPositionController {
log.info(String.valueOf(isPublishOk));
Thread.sleep(3000);

content = configService.getConfig(dataId, group, 5000);
configService = NacosFactory.createConfigService(properties);
content = configService.getConfig(dataId, group, 10000);
log.info(content);

content = configService.getConfig(positionId, group, 5000);
content = configService.getConfig(positionId, group, 10000);
log.info(content);

boolean isRemoveOk = configService.removeConfig(dataId, group);
log.info(String.valueOf(isRemoveOk));
Thread.sleep(3000);
//boolean isRemoveOk = configService.removeConfig(dataId, group);
//log.info(String.valueOf(isRemoveOk));
//Thread.sleep(3000);

content = configService.getConfig(dataId, group, 5000);
log.info(content);
Thread.sleep(30000);
//content = configService.getConfig(dataId, group, 10000);
//log.info(content);
//Thread.sleep(30000);

System.out.println(content);
//System.out.println(content);

return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}


Yükleniyor…
İptal
Kaydet