Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make the jar package of springboot start in service mode

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to make springboot's jar package start in service mode, I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.

Springboot's jar package launches the scene in service mode

The typed jar package can definitely be started with java-jar. This approach is inherently simple, but not friendly to operation and maintenance.

So the transformation is required, and it is hoped that it can be started with the service command.

Process

It's technically achievable.

Pom.xml configuration

There are 2 configuration points in pom.xml:

Custom-app org.springframework.boot spring-boot-maven-plugin true

Note: finalName should be unique and do not have a version number such as .1.1 snapshot.

Maven, Authorization, Startup

Package first, and then execute the following script:

# authorize chmod 755 custom-app; # start. / custom-app.jar

If it can be executed, it means that the maven configuration is in effect and the jar package becomes the execution file.

Note: look at the jar package and find that the shell script is added to the first 2300 lines, which is what true generates.

Also: java-jar is still available and will not be affected.

Establish a soft connection and start it with the service command

The command is as follows:

# establish a soft connection ln-s / data/custom-app.jar / etc/init.d/custom-app# and then start service custom-app start with the service command

It is found that the log is not output, so how is it started? How to read the log?

# here you can see the launched log / var/log/custom-app.log# to view the pid. The template is: / var/run//.pid/var/run/custom-app/custom-app.pidsystemctl configuration

Because it is not useful, for the time being.

The use of systemctl configuration is also found in the bottom spring document.

Other

Official website documentation on configuration

Springboot starts, shuts down in the form of jar packages, Restart script start script start script startup.shroud starting script start Starting applicationnohup java-jar activiti_demo-0.0.1-SNAPSHOT.jar & authorize chmod + x startup.sh to turn off writing shutdown script stop.shrunken grep grep activiti_demo-0.0.1-SNAPSHOT.jar | grep-v grep | awk'{print $2}') if [- z "$PID"] then echo Application is already stoppedelse echo kill $PID kill $PIDfi Authorization chmod + x stop.sh Reboot Writing restart script Restart.shendahBash Backecho Stopping applicationsource. / stop.shecho Starting applicationsource. / startup.sh Authorization chmod + x restart.sh above is all the content of the article "how to make the jar package of springboot start in service mode" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report