import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
@SpringBootApplication(scanBasePackages = {"com.test.**"})
@EnableDiscoveryClient
@EnableHystrix
@Slf4j
public class TestStartApplication {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(TestStartApplication.class, args);
Environment environment = context.getBean(Environment.class);
String port = environment.getProperty("server.port");
String ctxPath = environment.getProperty("server.servlet.context-path");
ctxPath = ctxPath == null ? "/" : ctxPath;
log.info("启动完成,系统访问地址:http://localhost:" + port + ctxPath + "doc.html");
}
}
sping系列: 在springboot启动类中获取运行端口
最新推荐文章于 2024-03-21 15:32:20 发布