ZdGatewayApplication.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.zd.gateway;
  2. import com.zd.common.core.launch.ZdStartApplication;
  3. import com.zd.model.constant.ApplicationConstants;
  4. import org.slf4j.Logger;
  5. import org.slf4j.LoggerFactory;
  6. import org.springframework.boot.autoconfigure.SpringBootApplication;
  7. import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
  8. import org.springframework.context.ConfigurableApplicationContext;
  9. import org.springframework.context.annotation.ComponentScan;
  10. import org.springframework.core.env.Environment;
  11. import java.net.InetAddress;
  12. import java.net.UnknownHostException;
  13. /**
  14. * 网关启动程序
  15. *
  16. * @author zd
  17. */
  18. @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
  19. @ComponentScan(basePackages ={"com.zd.common.core.redis","com.zd.gateway"} )
  20. public class ZdGatewayApplication {
  21. static Logger logger = LoggerFactory.getLogger(ZdGatewayApplication.class);
  22. public static void main(String[] args) {
  23. ConfigurableApplicationContext run = ZdStartApplication.run(ApplicationConstants.GATEWAY_SERVICE, ZdGatewayApplication.class, args);
  24. Environment env = run.getEnvironment();
  25. try {
  26. logger.info("\n----------------------------------------------------------\n\t" +
  27. "Application '{}' is running! Access URLs:\n\t" +
  28. "Local: \t\thttp://localhost:{}\n\t" +
  29. "External: \thttp://{}:{}\n\t" +
  30. "文档地址: \thttp://{}:{}/doc.html\n\t" +
  31. "----------------------------------------------------------",
  32. env.getProperty("spring.application.name"),
  33. env.getProperty("server.port"),
  34. InetAddress.getLocalHost().getHostAddress(),
  35. env.getProperty("server.port"),
  36. InetAddress.getLocalHost().getHostAddress(),
  37. env.getProperty("server.port")
  38. );
  39. } catch (UnknownHostException e) {
  40. e.printStackTrace();
  41. }
  42. }
  43. }