In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to install Spring boot application on Linux system, Xiaobian thinks it is quite practical, so share it with you as a reference, I hope you can gain something after reading this article.
Unix/Linux services
systemd service
operation
1. CentOS 7 virtual machine with JDK installed
Note that when downloading the Linux version of JDK can not be directly downloaded through wget this direct link, otherwise the decompression will not be successful, should open the original official website, click on the permission to click download (this way download is very slow), the better way is to copy the download page address to Thunder, through Thunder to open the download page, agree to the license click download.
After downloading, decompress and configure environment variables
tar -zxvf jdk1.8.0_211.jar.gz
Environment variable configuration: /etc/profile file Finally add the following
export JAVA_HOME=/var/java/jdk1.8.0_211export CLASSPATH=.:$ JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport PATH=$PATH:$JAVA_HOME/bin
After adding environment variables, execute source /etc/profile to make environment variables take effect.
2. Prepare the spring boot application for installation
2.1 For successful installation, pay particular attention to the configuration of plug-ins in the pom file. The correct example is as follows:
org.springframework.boot spring-boot-maven-plugin com.itsherman.dcm.Application true repackage
If you declare only the spring-boot-maven-plugin and ignore the following configuration items, it is likely that your package (jar) port has failed to launch in the past. Error: Main menu attribute not found.
The above problem is mainly because there is a META_INF folder in the executable jar package built. The MANIFEST.MF file under this folder describes the main information of the modified package, and the Main-Class line is missing. The solution is that we can add it manually, or follow the configuration above, especially without the execution configuration item, and then re-execute mvn install. After regenerating the jar package, open it through winrar tool and check the information of MANIFEST.MF file.
General complete file information is as follows:
Manifest-Version: 1.0Archiver-Version: Plexus ArchiverBuilt-By: ShermanStart-Class: com.itsherman.dcm.ApplicationSpring-Boot-Classes: BOOT-INF/classes/Spring-Boot-Lib: BOOT-INF/lib/Spring-Boot-Version: 2.1.5.RELEASECreated-By: Apache Maven 3.6.0Build-Jdk: 1.8.0_172Main-Class: org.springframework.boot.loader.JarLauncher
After that, try executing it locally using java -jar myapp.jar
3. Migrate jar package to virtual machine in step [1] through xftp and other file migration tools
4. Write the configuration file of the service under/etc/systemd/system on the virtual machine. The reference example is as follows:
[Unit]Description=myappAfter=syslog.target[Service]User=hadoopExecStart=/var/java/jdk1.8.0_211/bin/java -jar /home/hadoop/myapp/dev-manager.jarSuccessExitStatus=143[Install]WantedBy=multi-user.target
·Description: Description of the program
·User: System User
·ExecuStart: Command to start the program
After writing the configuration file, save and exit
. start the service
Refresh service configuration information
systemctl daemon-reload
start the service
systemctl start myapp.service
boot service
systemctl enable myapp.service
View service status information
systemctl status myapp.service
6. test
Open the browser and access the service.
About "how to install Spring boot application on Linux system" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.