ApplicationRun.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package com.usky.gateway;
  2. import org.slf4j.Logger;
  3. import org.slf4j.LoggerFactory;
  4. import org.springframework.boot.SpringApplication;
  5. import org.springframework.boot.autoconfigure.SpringBootApplication;
  6. import org.springframework.cloud.openfeign.EnableFeignClients;
  7. import org.springframework.context.ConfigurableApplicationContext;
  8. import org.springframework.context.annotation.ComponentScan;
  9. import org.springframework.core.env.Environment;
  10. import java.net.InetAddress;
  11. import java.net.UnknownHostException;
  12. /**
  13. * 应用启动模块
  14. *
  15. */
  16. @EnableFeignClients(basePackages = "com.usky")
  17. @ComponentScan("com.usky")
  18. @SpringBootApplication
  19. public class ApplicationRun
  20. {
  21. private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationRun.class);
  22. public static void main(String[] args) throws UnknownHostException {
  23. ConfigurableApplicationContext application = SpringApplication.run(ApplicationRun.class, args);
  24. Environment env = application.getEnvironment();
  25. String ip = InetAddress.getLocalHost().getHostAddress();
  26. String port = env.getProperty("server.port");
  27. String path = env.getProperty("server.servlet.context-path");
  28. LOGGER.info("\n----------------------------------------------------------\n\t" +
  29. "Application is running! Access URLs:\n\t" +
  30. "Local: \t\thttp://localhost:" + port + (null==path?"":path) + "/\n\t" +
  31. "External: \thttp://" + ip + ":" + port + (null==path?"":path) + "/\n\t" +
  32. "Api: \t\thttp://" + ip + ":" + port + (null==path?"":path) + "/swagger-ui/index.html\n\t" +
  33. "----------------------------------------------------------");
  34. }
  35. }