File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
generator-web/src/main/java/com/softdev/system/generator Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 5
5
import org .springframework .boot .autoconfigure .SpringBootApplication ;
6
6
7
7
@ SpringBootApplication
8
- @ Slf4j
9
8
public class GeneratorWebApplication {
10
9
public static void main (String [] args ) {
11
10
SpringApplication .run (GeneratorWebApplication .class ,args );
12
- log .info ("项目启动启动成功!访问地址: http://localhost:1234/generator" );
13
11
}
14
12
}
Original file line number Diff line number Diff line change
1
+ package com .softdev .system .generator .config ;
2
+
3
+ import lombok .extern .slf4j .Slf4j ;
4
+ import org .springframework .boot .web .context .WebServerInitializedEvent ;
5
+ import org .springframework .context .ApplicationListener ;
6
+ import org .springframework .stereotype .Component ;
7
+
8
+ /**
9
+ * @Description 动态获取tomcat启动端口,控制台打印项目访问地址
10
+ * @Author Gao Hang Hang
11
+ * @Date 2019-12-27 14:37
12
+ **/
13
+ @ Component
14
+ @ Slf4j
15
+ public class ServerConfig implements ApplicationListener <WebServerInitializedEvent > {
16
+
17
+ private int serverPort ;
18
+
19
+ public int getPort () {
20
+ return this .serverPort ;
21
+ }
22
+
23
+ @ Override
24
+ public void onApplicationEvent (WebServerInitializedEvent event ) {
25
+ this .serverPort = event .getWebServer ().getPort ();
26
+ //log.info("Get WebServer port {}", serverPort);
27
+ log .info ("项目启动启动成功!访问地址: http://localhost:{}/generator" , serverPort );
28
+ }
29
+
30
+ }
You can’t perform that action at this time.
0 commit comments