RuoYiApplication.java
2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.ruoyi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import javax.annotation.PostConstruct;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 启动程序
*
* @author guzijian
*/
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class RuoYiApplication {
private final static Logger log = LoggerFactory.getLogger(RuoYiApplication.class);
public static void main(String[] args) throws UnknownHostException {
// System.setProperty("spring.devtools.restart.enabled", "false");
ConfigurableApplicationContext app = SpringApplication.run(RuoYiApplication.class, args);
ConfigurableEnvironment env = app.getEnvironment();
log.info("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' \n");
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
String redisPort = env.getProperty("spring.redis.port");
String redisHost = env.getProperty("spring.redis.host");
String sqlUrl = env.getProperty("spring.datasource.druid.master.url");
List<String> sqlInfo = getSqlInfo(sqlUrl);
log.info(
"\n Swagger访问地址:http://" + ip + ":" + port + path + "swagger-ui/index.html \n" +
" Redis服务器地址:" + redisHost + ":" + redisPort + "\n" +
" Mysql服务器地址:" + sqlInfo.get(0) + ":" + sqlInfo.get(1));
}
private static List<String> getSqlInfo(String sqlInfo) {
List<String> str = new ArrayList<>(3);
Pattern pattern = Pattern.compile("jdbc:mysql://([a-zA-Z0-9.-]+):(\\d+)/");
Matcher matcher = pattern.matcher(sqlInfo);
if (matcher.find()) {
str.add(matcher.group(1));
str.add(matcher.group(2));
}
return str;
}
}