话不多说,直接上代码(喜欢的留下个赞吧)
package cn.tj.runner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
/**
* Created with IntelliJ IDEA.
*
* @Author: Zp
* @Date: 2022/03/15/18:45
* @Description:
*/
@Component
public class TjWebApplicationEunner implements ApplicationRunner{
private Logger log = LoggerFactory.getLogger(this.getClass());
@Value("${server.port}")
private int prot; //端口号,在yml或者properties配置文件中的端口号
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("XXX项目部署完成,访问地址:http://localhost:"+prot);
}
}