“This is the third day of my participation in the August More Text Challenge. For details, see: August More Text Challenge.”

I am a novice, just to record the learning process, if there are any omissions and mistakes, I hope you can point them out, thank you, thank you.

Spring Can Boot program, the built-in Tomcat, jetty, Undertow, Netty container, such as when we add the second day of spring – the Boot – starter – web depend on, can make the Tomcat default, want to configure Tomcat, can in the application. Properties file. First, we are familiar with Tomcat, so the question is where is the application.properties file? So it’s very simple under Resources, we’re going to set it up, as you know,Tomcat’s default port is 8080, so let’s change that. The code is as follows.

server.port=8081
server.error.path=/error
server.servlet.session.timeout=30m
server.servlet.context-path=/demo
server.tomcat.uri-encoding=utf-8
server.tomcat.threads.max=500
Copy the code

Let me just take a picture of it for you to remember

Server.error. Path =/error # Change session timeout to minutes (default: seconds), but Tomcat configures sessions in minutes (for example, 179), which translates to less than three minutes . Server. The servlet. The session timeout = 30 m # change is the project name, if not all write by default/server. The servlet. The context - path = # / demo setup tomcat request code Server. Tomcat. Uri - encoding = utf-8 # set the maximum number of threads tomcat server tomcat. Threads. Max = 500Copy the code

For more details, see the docs.spring. IO /spring-boot…

Stick a picture

So let’s see what happens. I wrote the simplest SpringBoot HelloWorld yesterday, so let’s change the configuration and see if it works. Let’s see what happens.

Before the change

After the change

Do not be afraid to change the port number and path address in the configuration file. The correct result is this.

Good for you. You’ve accomplished a few days of small goals. Let’s record the HTTPS configuration

HTTPS configuration for Spring Boot

Some cloud service vendors also provide free certificates. Java SDK also provides one,Keytools, in the JDK \bin directory

Open CMD in this path

keytool -genkey -alias tomcat -keyalg RSA -keysize 2048 -keystore https.rsa -validity 365

Enter the above command: explain to make the keytool tool – generate – alias (whatever)- encryption algorithm RSA- key length 2048- location (not specified in the current directory) file name – valid 365 days little by little can be compared to see.

Copy this file to the root path of your project and configure the application.properties file

#keytool -genkey -alias tomcat -keyalg RSA -keysize 2048 -keystore https.rsa -validity 365
server.ssl.key-store=https.rsa
server.ssl.key-alias=tomcat
server.ssl.key-store-password=123456
Copy the code

rendering

Restart the project and refresh the web page

Don’t be nervous to read the hint, this is a bad request and requires a combination of host name and port number TLS

So the question is what TLS is: Transport Layer security protocol (from Baidu) so the solution is obvious +https://

Resolve renderings

It’s not safe without money. Keep going. Get to the final chart

Finally, if you use HTTP after configuring HTTPS, you will fail. You need to configure request redirection to solve this problem.

2021-8-9 Another happy day