Linux β’ Web Apps & APIs
How to Create a Systemd Service for Java Spring Boot JAR
Spring Boot packages applications into executable fat JARs. Running Spring Boot under systemd allows you to configure JVM memory limits (`-Xmx`, `-Xms`), log redirection, and automated restarts.
/etc/systemd/system/spring-app.service
[Unit]
Description=Spring Boot Enterprise Service
After=syslog.target network.target
[Service]
Type=simple
User=spring
Group=spring
WorkingDirectory=/opt/spring-app
ExecStart=/usr/bin/java -Xms512m -Xmx2048m -jar app.jar --spring.profiles.active=prod
SuccessExitStatus=143
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.targetCustomize:
User:
WorkingDir:
ExecStart:
Systemctl Lifecycle & Journalctl Monitoring
sudo systemctl daemon-reloadRegister servicesudo systemctl enable --now spring-appStart Spring Boot JAR and enable on bootsudo journalctl -u spring-app -fWatch live Spring Boot startup banner and logsLinux & Systemd Production Best Practices
- `SuccessExitStatus=143` tells systemd that Exit Code 143 (SIGTERM graceful shutdown in Java) is a planned success, not a service failure.
Frequently Asked Questions About Java Spring Boot Service
Frequently Asked Questions
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
Placing `application.properties` inside the `WorkingDirectory` (`/opt/spring-app/`) will cause Spring Boot to automatically load it with higher priority over internal JAR properties.
Related Linux & Systemd Services
View All ServicesWeb Apps & APIs
How to Create a Systemd Service for Node.js (Express, NestJS, Next.js)
node-app.serviceGuide β
Web Apps & APIs
How to Create a Systemd Service for Python (FastAPI, Flask, Gunicorn, Uvicorn)
python-app.serviceGuide β
Web Apps & APIs
How to Create a Systemd Service for Go (Golang) Compiled Binary
go-service.serviceGuide β
Background Workers & Daemons
How to Run Background Workers (Celery, BullMQ, Sidekiq) with Systemd
queue-worker.serviceGuide β
Timers & Automation
How to Create a Systemd Timer to Replace Cron Jobs
backup-task.serviceGuide β
Infrastructure & Tunnels
How to Run Docker Compose as a Systemd Service
docker-compose-app.serviceGuide β