Selaa lähdekoodia

增加配置文件读取

tags/v1.0.0^2
林万龙 3 vuotta sitten
vanhempi
commit
a3b512535d
1 muutettua tiedostoa jossa 23 lisäystä ja 1 poistoa
  1. +23
    -1
      src/main/java/com/telpo/dipperposition/DipperPositionApplication.java

+ 23
- 1
src/main/java/com/telpo/dipperposition/DipperPositionApplication.java Näytä tiedosto

@@ -1,5 +1,10 @@
package com.telpo.dipperposition;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.exception.NacosException;
import com.telpo.dipperposition.server.DipperPositionServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
@@ -8,7 +13,8 @@ import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import java.net.InetSocketAddress;
import java.util.Properties;
import java.util.concurrent.Executor;

/**
* @program: gateway
@@ -27,10 +33,26 @@ public class DipperPositionApplication {
log.info("北斗定位服务开始!");
SpringApplication.run(DipperPositionApplication.class, args);
log.info("北斗定位服务启动!");
try {
test();
} catch (Exception e) {
log.error(e.getMessage());
}
//启动服务端
DipperPositionServer nettyServer = new DipperPositionServer();
nettyServer.startTimeAsnc();
nettyServer.startPosAsnc();
nettyServer.startStarsAsnc();
}

private static void test() throws NacosException {
String serverAddr = "172.16.192.26";
String dataId = "dipperposition-service";
String group = "DEFAULT_GROUP";
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
ConfigService configService = NacosFactory.createConfigService(properties);
String content = configService.getConfig(dataId, group, 5000);
System.out.println(content);
}
}

Loading…
Peruuta
Tallenna