Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@Slf4j
public class GeneratorWebApplication {
public static void main(String[] args) {
SpringApplication.run(GeneratorWebApplication.class,args);
log.info("项目启动启动成功!访问地址: http://localhost:1234/generator");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.softdev.system.generator.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
* @Description 动态获取tomcat启动端口,控制台打印项目访问地址
* @Author Gao Hang Hang
* @Date 2019-12-27 14:37
**/
@Component
@Slf4j
public class ServerConfig implements ApplicationListener<WebServerInitializedEvent> {

private int serverPort;

public int getPort() {
return this.serverPort;
}

@Override
public void onApplicationEvent(WebServerInitializedEvent event) {
this.serverPort = event.getWebServer().getPort();
//log.info("Get WebServer port {}", serverPort);
log.info("项目启动启动成功!访问地址: http://localhost:{}/generator", serverPort);
}

}