SpringBoot打印启动端口

SpringBoot打印出启动端口,使用之前需要先引进log

private static final Logger LOG = LoggerFactory.getLogger(WikiApplication.class);
 SpringApplication app = new SpringApplication(WikiApplication.class);
        Environment env = app.run(args).getEnvironment();
        LOG.info("启动成功!!");
        LOG.info("地址: \thttp://localhost:{}", env.getProperty("server.port"));

完整示例

public class Application {

    private static final Logger LOG = LoggerFactory.getLogger(Application.class);

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(WikiApplication.class);
        Environment env = app.run(args).getEnvironment();
        LOG.info("启动成功!!");
        LOG.info("地址: \thttp://localhost:{}", env.getProperty("server.port"));
    }

}

你可能感兴趣的:(springboot,spring)