Spring boot\'s preferred deployment method is via a executable jar file which contains tomcat inside.
It is started with a simple java -jar myapp.jar
.>
By far the most easiest and reliable way to run Spring Boot applications in production is with Docker. Use Docker Compose, Docker Swarm or Kubernetes if you need to use multiple connected services.
Here's a simple Dockerfile
from the official Spring Boot Docker guide to get you started:
FROM frolvlad/alpine-oraclejdk8:slim
VOLUME /tmp
ADD YOUR-APP-NAME.jar app.jar
RUN sh -c 'touch /app.jar'
ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
Here's a sample command line to run the container as a daemon:
docker run \
-d --restart=always \
-e "SPRING_PROFILES_ACTIVE=prod" \
-p 8080:8080 \
prefix/imagename