The console adjusts the zero-time variable when java Spring Boot goes online and starts the jar

The previous article Java package the Spring Boot project and run in the Windows system and the packaging and deployment of the Spring Boot project to the Alibaba Cloud Linux server to tell the process of the packaging deployment of the Spring Boot project,
but here we may encounter a situation at this time. At this time, our server Java project takes up 80 but we need to put on a more important thing. We need Need to use the 80 our Java project to be changed to port 8080, so we have configured in the project's Application.yml configuration file, but we pack
it
up
insert image description here
.

For example, we now start this program on port 80.
insert image description here
Here we use http://localhost/books to call and return the result, everything is normal.
insert image description here
Then we stop the program and enter it as usual

java -jar WebDom-0.0.1-SNAPSHOT.jar

insert image description here
It can also be followed by temporary variables
, such as this
insert image description here

java -jar WebDom-0.0.1-SNAPSHOT.jar --server.port=8080

insert image description here
Change the started server.port to 8080 at zero time
and press Enter to run

Our console outputs port 8080.
insert image description here
At this time, we can use the default port 80 to call the interface, but he can’t find it.
insert image description here
But we can run normally again with the following: 8080.
insert image description here
Here, our single zero-time variable has been fixed.

But some people may say what if I want to change two?

Then let's change the password of the database so that he can't connect to the database to see the effect.
insert image description here
Our terminal stops the program and enters

java -jar WebDom-0.0.1-SNAPSHOT.jar --server.port=8080 --spring.datasource.druid.password=erw

In fact, it is as simple as that. Multiple zero-time variables are empty after the previous zero-time variable. Then -- the corresponding value is fine.
This time we changed the database link password to erw, which is a wrong password. We press Enter to run the program.

Of course, the error of the database password will not affect the startup of our java project.
insert image description here
The result will not be found after re-running
insert image description here
. At the same time, our console is always reporting errors.
insert image description here

Guess you like

Origin blog.csdn.net/weixin_45966674/article/details/131858491