|
1 | 1 | package com.fengwenyi.codegenerator;
|
2 | 2 |
|
3 | 3 | import com.fengwenyi.apistarter.EnableApiStarter;
|
| 4 | +import lombok.extern.slf4j.Slf4j; |
4 | 5 | import org.springframework.boot.SpringApplication;
|
5 | 6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
|
| 7 | +import org.springframework.context.ApplicationContext; |
| 8 | +import org.springframework.core.env.Environment; |
| 9 | + |
| 10 | +import java.net.InetAddress; |
| 11 | +import java.net.UnknownHostException; |
6 | 12 |
|
7 | 13 | /**
|
8 | 14 | * @author <a href="https://www.fengwenyi.com">Erwin Feng</a>
|
9 | 15 | * @since 2021-07-12
|
10 | 16 | */
|
11 | 17 | @SpringBootApplication
|
12 | 18 | @EnableApiStarter
|
| 19 | +@Slf4j |
13 | 20 | public class MyBatisPlusCodeGeneratorApplication {
|
14 | 21 |
|
15 | 22 | public static void main(String[] args) {
|
16 |
| - SpringApplication.run(MyBatisPlusCodeGeneratorApplication.class, args); |
| 23 | + ApplicationContext application = SpringApplication.run(MyBatisPlusCodeGeneratorApplication.class, args); |
| 24 | + Environment env = application.getEnvironment(); |
| 25 | + String ip; |
| 26 | + try { |
| 27 | + ip = InetAddress.getLocalHost().getHostAddress(); |
| 28 | + } catch (UnknownHostException e) { |
| 29 | + throw new RuntimeException(e); |
| 30 | + } |
| 31 | + String port = env.getProperty("server.port"); |
| 32 | + String appName = env.getProperty("spring.application.name"); |
| 33 | + String path = env.getProperty("server.servlet.context-path"); |
| 34 | + |
| 35 | + String msg = "\n---------------------------------------------------------------------------" |
| 36 | + + "\n\tApplication "+ appName + " is running! Access URLs:" |
| 37 | + + "\n\tLocal: \t\thttp://localhost:" + port |
| 38 | + + "\n\tExternal: \thttp://" + ip + ":" + port |
| 39 | + + "\n---------------------------------------------------------------------------" |
| 40 | + ; |
| 41 | + |
| 42 | + log.info(msg); |
17 | 43 | }
|
18 | 44 |
|
19 | 45 | }
|
0 commit comments