This article is a mirror article of machine translation, please click here to jump to the original article.

View: 28806|Reply: 2

[Source] Spring overrides the default configuration inside the jar package

[Copy link]
Posted on 10/28/2021 9:44:51 AM | | | |
Requirements: Publishing the jar package to different environments, the configuration of different environments is different, for example: spring.profiles.active or server.port is different, after we modify the configuration file, it will be very troublesome to type it into different jar packages.

In fact, spring can replace the default configuration inside the jar package through environment variables, command-line arguments, and configuration files.

Command line arguments

You can replace the boot port or activate the configuration of a different environment in the following two ways:

environment variable

For example, on a Linux system, the command is as follows:

Reference:The hyperlink login is visible.

Configuration files

We modify the jar package into a zip file and open it, find the \BOOT-INF\classes directory, and put the directory in itapplication.propertiesCopy it as shown below:





After modifying the application.properties file, put the file and the jar package in the same directory and restart the Java application, as shown in the figure below:



Note: config/application.properties has a higher priority than application.properties





Previous:Test the basic parameter information of your Linux server with one click
Next:Docker looks at container restart settings and bulk stop containers
Posted on 10/29/2021 11:43:10 PM |
Not bad, not bad, learn to learn
 Landlord| Posted on 11/14/2021 8:04:26 PM |
Java modifies the configuration file of the war package
https://www.itsvse.com/thread-10146-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com