Home > OS >  Create service Java spring ubuntu
Create service Java spring ubuntu

Time:02-01

how to create Linux service Java spring ?

This is my /etc/systemd/system/javatest.service config

[Unit]
Description=A Spring Boot application
After=syslog.target

[Service]
User=baeldung
ExecStart= /usr/bin/java jar -Dspring.profiles.active=dev provider-integration-api.jar -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
SuccessExitStatus = 143    
[Install]
WantedBy=multi-user.target

This not working but this 2 config working , how to start with java options ?

This Working

[Unit]
    Description=A Spring Boot application
    After=syslog.target
    
    [Service]
    User=baeldung
    ExecStart=/opt/Java-provider-api/provider-integration-api.jar 
    jcSuccessExitStatus=143 
    
    [Install]
    WantedBy=multi-user.target

CodePudding user response:

The command should looks like:
ExecStart=/usr/bin/java -jar -Dspring.profiles.active=dev -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector provider-integration-api.jar

Pay attention on:

  • you should use -jar and not jar

  • options (system properties in your case, which start from -D) should be put before the .jar file; if you will put something after .jar file it will be taken as an arguments

See the documentation.

  •  Tags:  
  • Related