[JAVA] How to run the SpringBoot app as a service


  1. Creating a Fully Executable Jar
  2. Creating a conf file
  3. Service registration

1. Creating a Fully Executable Jar

If you make a Jar in the form of Fully Executable Jar, a script will be added to the beginning of the Jar and output. This script can be used as it is as a script for starting the service.

To create it, make the contents of the <build> tag in pom.xml as follows.



<executable> true </ executable> is the key

2. Creating a conf file

Create a file with the same name as the Jar file to be executed but with the extension changed to .conf. The contents are the definition of environment variables, options to be passed to java, and runtime arguments to be passed to jar.

Environment variables are usually ╩╗export`

export LANG="ja_JP.UTF8"

java option is JAVA_OPTS

JAVA_OPTS="-Xms1024M -Xmx1024M"

The run-time argument is RUN_ARGS


Service registration

For systemd such as CentOS7, it is OK if you create a service file in / etc / systemd / system /


Description = <Service description>

ExecStart = /home/application/hoge.jar
Restart = always
Type = simple
User = application
Group = application
SuccessExitStatus = 143

WantedBy = multi-user.target

with this

$ sudo systemctl start hoge

Can do something

Recommended Posts

How to run the SpringBoot app as a service
How to run a Kotlin Coroutine sample from the command line
[SpringBoot] How to write a controller test
How to interact with a server that does not crash the app
How to run a GIF file from the Linux command line (Ubuntu)
How to get the current date as a string in yyyyMMdd format
How to add sound in the app (swift)
[Swift] How to link the app with Firebase
How to run a djUnit task in Ant
Run autossh as a systemd service on CentOS
The road to creating a Web service (Part 1)
How to build Docker + Springboot app (for basic learning)
Spring-Boot-2.3 requires javax.validation to be added as a dependency
How to make a mod for Slay the Spire
How to get started with creating a Rails app
How to leave a comment
How to insert a video
How to create a method
How to take a screenshot with the Android Studio emulator
How to request a CSV file as JSON with jMeter
How to transition from the [Swift5] app to the iPhone settings screen
SDWebImage: How to clear the cache for a particular UIImageView
How to deploy a simple Java Servlet app on Heroku
[iOS] [Objective-C] How to update a widget from an Objective-C app
How to create a form to select a date from the calendar
How to create a placeholder part to use in the IN clause
[Java] Deploy the Spring Boot application to Azure App Service
How to get the longest information from Twitter as of 12/12/2016
How to change the setting value of Springboot Hikari CP
How to deploy a kotlin (java) app on AWS fargate
[Ruby] How to retrieve the contents of a double hash
How to add the same Indexes in a nested array
How to develop and register a Sota app in Java
How to install GNOME as a desktop environment on CentOS 7
How to run React and Rails on the same server
Learn how to customize the Navigation Bar from the sample app
How to create a service builder portlet in Liferay 7 / DXP
[jsoup] How to get the full amount of a document
How to batch run JUnit and get coverage as well
How to register as a customer with Square using Tomcat
[Android] How to check if the Google Play developer service is installed when the app is launched
How to use the link_to method
How to create a jar file or war file using the jar command
How to use the include? method
How to add columns to a table
How to use the form_with method
I want to create a chat screen for the Swift chat app!
How to run JUnit in Eclipse
How to create a registration / update function where the table crosses
[Swift] How to display when the quiz app answers correctly [Beginner]
How to find the average angle
How to run Ant in Gradle
How to make Ubuntu a fixed IP address on the command line (explained as carefully as possible)
How to run a mock server on Swagger-ui using stoplight/prism (using AWS/EC2/Docker)
How to make a Java container
How to use the wrapper class
How to sign a Minecraft MOD
How to make a JDBC driver
How to run JavaFX on Docker
How to deploy an app that references a local jar to heroku
[Java] How to create a folder