Answer the question
In order to leave comments, you need to log in
How to build a java project on maven into a jar file and put it on ubuntu server 18.04?
I'm interested in a number of questions:
1) How to properly build java on maven, taking into account all the nuances?
2) How to transfer jar file to ubuntu 18.04 server?
3) How to run jar file on server?
Thanks everyone for the replies!
Answer the question
In order to leave comments, you need to log in
1. The repository usually has all the necessary configs and bindings
2. Just like any other file
3.java -jar /path/to/your-file.jar
Good afternoon.
You can deploy the application in different ways.
One possible way is docker or docker-compose.
Steps:
1 - create a Dockerfile, specify how the project should be built, what should be installed, etc.
For example,
FROM adoptopenjdk/openjdk11:jdk-11.0.10_9-alpine as build
COPY . /srv
RUN cd /srv && chmod +x mvnw && ./mvnw clean package
FROM adoptopenjdk/openjdk11:jdk-11.0.10_9-alpine
WORKDIR /srv
COPY --from=build /srv/target/{JAR_NAME}.jar /srv/{JAR_NAME}.jar
ENTRYPOINT exec java -jar /srv/{JAR_NAME}.jar
mvn clean package
java -jar /srv/{JAR_NAME}.jar
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question