Przeglądaj źródła

增加OkHttp配置文件读取

tags/v1.0.0^2
林万龙 3 lat temu
rodzic
commit
2e7c33a428
2 zmienionych plików z 12 dodań i 8 usunięć
  1. +6
    -3
      src/main/java/com/telpo/dipperposition/DipperPositionApplication.java
  2. +6
    -5
      src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java

+ 6
- 3
src/main/java/com/telpo/dipperposition/DipperPositionApplication.java Wyświetl plik

@@ -44,9 +44,12 @@ public class DipperPositionApplication {
log.info("北斗定位服务启动!");
//启动服务端
ConfigurableEnvironment environment = applicationContext.getEnvironment();
PositionConfigInfo pci;
pci = (PositionConfigInfo)environment.getSystemProperties().get("position-server");
DipperPositionServer nettyServer2 = new DipperPositionServer(pci);
log.info(environment.toString());
log.info(environment.getProperty("position-server"));
//PositionConfigInfo pci;
//pci = (PositionConfigInfo)environment.getProperty("position-server");
DipperPositionServer nettyServer2 = new DipperPositionServer(environment);
log.info(environment.getSystemProperties().toString());
nettyServer2.start();
} catch (Exception e) {
log.error(e.getMessage());


+ 6
- 5
src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java Wyświetl plik

@@ -13,6 +13,7 @@ import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.env.ConfigurableEnvironment;

import java.net.InetSocketAddress;

@@ -31,12 +32,12 @@ public class DipperPositionServer {
private Integer posAsycPort;
private Integer starsAsycPort;

public DipperPositionServer(PositionConfigInfo pci) throws NacosException {
public DipperPositionServer(ConfigurableEnvironment environment) throws NacosException {

this.serverAddr = pci.getServerAddr();
this.timeAsycPort = Integer.parseInt(pci.getTimeAsycPort());
this.posAsycPort = Integer.parseInt(pci.getPosAsycPort());
this.starsAsycPort = Integer.parseInt(pci.getStarsAsycPort());
this.serverAddr = environment.getProperty("position-server.serverAddr");
this.timeAsycPort = Integer.parseInt(environment.getProperty("position-server.timeAsycPort"));
this.posAsycPort = Integer.parseInt(environment.getProperty("position-server.posAsycPort"));
this.starsAsycPort = Integer.parseInt(environment.getProperty("position-server.starsAsycPort"));
//String serverAddr = positionConfigInfo.getServerAddr();
// try {
// try {


Ładowanie…
Anuluj
Zapisz