启动类的优化

发布时间:2024年01月18日

1.V1.0

?

package com.itheima.reggie;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;

@Slf4j
@SpringBootApplication
@ServletComponentScan
@EnableTransactionManagement
public class ReggieApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext application = SpringApplication.run(ReggieApplication.class, args);
        Environment env = application.getEnvironment();
        String port = env.getProperty("server.port");
        log.info("\n----------------------------------------------------------\n\t" +
                "running success! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port +"/backend/page/login/login.html"+"\n\t" +
                "Swagger文档: \thttp://localhost:" + port + "/doc.html\n" +
                "----------------------------------------------------------");
    }
}

文章来源:https://blog.csdn.net/m0_59690068/article/details/135668172
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。