Reprinted from www.cnblogs.com/wookong/p/1…
1. There are two types of Springboot package: JAR package and WAR package
| – into jars
CMD –> project root path –> MVN Clean Package –> Generated JAR package under target
| – WAR file
First modify the POM file
WAR
The second step adds project packaging dependencies
Third, remove the built-in Tomcat
Step 4 Pack
CMD –> project root path –> MVN Clean Package –> Generated JAR package under target
2. Configure HTTPS
(1). Prepare the domain name for record
(2). Prepare the certificate. Aliyun has a free certificate with a validity period of one year
Modify port and add SSL:
(3). Put the certificate under Resources
(4). Modify tomcat configuration
Put a copy of the certificate in the conf of Tomcat
Startup Class Configuration
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
|
`@Bean`
`public` `Connector connector(){`
`Connector connector=“new` `Connector(“”org.apache.coyote.http11.Http11NioProtocol”“); `
`connector.setScheme(“”http”“); `
`connector.setPort(80); `
`connector.setSecure(“false“); `
`connector.setRedirectPort(443); `
`return` `connector; `
`} `
`@Bean`
`public` `TomcatServletWebServerFactory tomcatServletWebServerFactory(Connector connector){`
`TomcatServletWebServerFactory tomcat=“new` `TomcatServletWebServerFactory(){`
`@Override`
`protected` `void` `postProcessContext(Context context) {`
`SecurityConstraint securityConstraint=“new` `SecurityConstraint(); `
`securityConstraint.setUserConstraint(“”CONFIDENTIAL”“); `
`SecurityCollection collection=“new` `SecurityCollection(); `
`collection.addPattern(“”/*”“); `
`securityConstraint.addCollection(collection); `
`context.addConstraint(securityConstraint); `
`} `
`}; `
`tomcat.addAdditionalTomcatConnectors(connector); `
`return` `tomcat; `
`} `
|
So far all configurations are OK.
Summary: 1. Start the class add code jump
2. Change the YML port number and add SSL
3. If it is a WAR package, modify the POM file
4. If the Tomcat server is used, modify the Tomcat configuration