北斗定位
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

66 lignes
2.5KB

  1. package com.telpo.dipperposition;
  2. import com.alibaba.nacos.api.NacosFactory;
  3. import com.alibaba.nacos.api.config.ConfigService;
  4. import com.alibaba.nacos.api.config.listener.Listener;
  5. import com.alibaba.nacos.api.PropertyKeyConst;
  6. import com.alibaba.nacos.api.exception.NacosException;
  7. import com.telpo.dipperposition.co.PositionConfigInfo;
  8. import com.telpo.dipperposition.server.DipperPositionServer;
  9. import com.telpo.dipperposition.server.EphAsyncServer;
  10. import com.telpo.dipperposition.server.TimeAsyncServer;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.springframework.boot.SpringApplication;
  13. import org.springframework.boot.autoconfigure.SpringBootApplication;
  14. import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
  15. import org.springframework.boot.context.properties.EnableConfigurationProperties;
  16. import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  17. import org.springframework.context.ConfigurableApplicationContext;
  18. import org.springframework.core.env.ConfigurableEnvironment;
  19. import org.springframework.scheduling.annotation.EnableAsync;
  20. import org.springframework.scheduling.annotation.EnableScheduling;
  21. import java.util.Properties;
  22. import java.util.concurrent.Executor;
  23. /**
  24. * @program: gateway
  25. * @description: 网关启动类
  26. * @author: linwl
  27. * @create: 2020-06-18 16:39
  28. */
  29. @SpringBootApplication
  30. @EnableDiscoveryClient
  31. @ConfigurationPropertiesScan
  32. @EnableAsync
  33. @EnableScheduling
  34. @Slf4j
  35. public class DipperPositionApplication {
  36. public static void main(String[] args) {
  37. try {
  38. log.info("北斗定位服务开始!");
  39. ConfigurableApplicationContext applicationContext = SpringApplication.run(DipperPositionApplication.class, args);
  40. log.info("北斗定位服务启动!");
  41. //启动服务端
  42. ConfigurableEnvironment environment = applicationContext.getEnvironment();
  43. PositionConfigInfo pci;
  44. pci = (PositionConfigInfo)environment.getSystemProperties().get("position-server");
  45. DipperPositionServer nettyServer2 = new DipperPositionServer(pci);
  46. } catch (Exception e) {
  47. log.error(e.getMessage());
  48. }
  49. }
  50. private static void test() throws NacosException {
  51. String serverAddr = "172.16.192.26";
  52. String dataId = "dipperposition-service";
  53. String group = "DEFAULT_GROUP";
  54. Properties properties = new Properties();
  55. properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
  56. ConfigService configService = NacosFactory.createConfigService(properties);
  57. String content = configService.getConfig(dataId, group, 5000);
  58. System.out.println(content);
  59. }
  60. }