浏览代码

增加OkHttp配置文件读取

tags/v1.0.0^2
林万龙 3 年前
父节点
当前提交
2e7c33a428
共有 2 个文件被更改,包括 12 次插入8 次删除
  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 查看文件

@@ -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 查看文件

@@ -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 {


正在加载...
取消
保存