Maven: Build a executable JAR

Prepare java deploy package

In true microservice architecture we need to prepare self sufficient applications which must be very easy to deploy. For java server app this means executable JAR file with all dependencies included.

Because I use spring boot application my application already is self sufficient. I only need to prepare a combined JAR with all dependencies.

Maven

In the maven pom.xml file I add build plugin:

After executing a maven “package” lifecycle command, maven will produce combined JAR with everything inside in the target folder :

Now I can run whole server app with simple jar command:

Because this executable jar include everything, web server, drivers, configurations etc, it will immediately serve REST services to the world.

Such an application could be deployed to any virtual machine instance locally or on the cloud.

You can get source code of this project from github repository “SpringBootMyApp” .

 

Leave a Reply

Your email address will not be published.