Bladeren bron

增加配置文件读取

tags/v1.0.0^2
林万龙 3 jaren geleden
bovenliggende
commit
f4273be990
2 gewijzigde bestanden met toevoegingen van 12 en 11 verwijderingen
  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 Bestand weergeven

@@ -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 Bestand weergeven

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


Laden…
Annuleren
Opslaan