|
1
2
|
package org.jeecg;
|
|
3
|
import lombok.extern.slf4j.Slf4j;
|
|
4
|
import org.apache.catalina.Context;
|
|
5
|
import org.apache.catalina.connector.Connector;
|
|
6
|
import org.apache.tomcat.util.scan.StandardJarScanner;
|
|
7
|
import org.jeecg.common.util.oConvertUtils;
|
|
8
9
|
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
10
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
11
|
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
|
|
12
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
|
13
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
|
14
|
import org.springframework.context.ConfigurableApplicationContext;
|
|
15
|
import org.springframework.context.annotation.Bean;
|
|
16
|
import org.springframework.core.env.Environment;
|
|
17
|
|
|
18
19
20
|
import java.net.InetAddress;
import java.net.UnknownHostException;
|
|
21
22
23
|
/**
* 单体启动类(采用此类启动项目为单体模式)
*/
|
|
24
25
|
@Slf4j
@SpringBootApplication
|
|
26
|
public class JeecgSystemApplication extends SpringBootServletInitializer {
|
|
27
|
|
|
28
|
@Override
|
|
29
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
|
30
|
return application.sources(JeecgSystemApplication.class);
|
|
31
32
33
|
}
public static void main(String[] args) throws UnknownHostException {
|
|
34
|
ConfigurableApplicationContext application = SpringApplication.run(JeecgSystemApplication.class, args);
|
|
35
36
37
|
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
|
|
38
|
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
|
|
39
40
41
42
|
log.info("\n----------------------------------------------------------\n\t" +
"Application Jeecg-Boot is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
|
|
43
|
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
|
44
45
46
47
48
49
50
51
52
|
"----------------------------------------------------------");
}
/**
* tomcat-embed-jasper引用后提示jar找不到的问题
*/
@Bean
public TomcatServletWebServerFactory tomcatFactory() {
|
|
53
54
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(){
|
|
55
56
57
58
59
|
@Override
protected void postProcessContext(Context context) {
((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
}
};
|
|
60
61
62
63
64
65
66
67
68
69
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
connector.setProperty("relaxedPathChars", "\"<>[\\]^`{|}");
connector.setProperty("relaxedQueryChars", "\"<>[\\]^`{|}");
}
});
return factory;
|
|
70
|
}
|
|
71
|
}
|