Tip: How to Package/Run Spring Boot Maven App as a JAR

Working with the Spring Tool Suite IDE (Integrated Development Environment) over time has taught me much, particularly about using Maven projects. While Gradle is an alternative, I have yet to use it and have been mainly using Maven because of the convenience of its POM.xml file to inject dependencies into my project and mass import dozens of needed .jar (Java Archive) files using only a few lines.

I will be using Windows OS for this guide. After writing up a Maven project in STS (Spring Tool Suite) and successfully running it in Spring Boot, it’s time to build it as a executable JAR! Bundle it up and wrap a pretty bow on it for others’ use.

  1. Ensure Maven is manually installed, not only for use within STS.
  2. Establish the JAVA_HOME Environment Variable if you hadn’t yet done so, pointing to your JDK. Powershell requires a compiler to build your JAR.
  3. Edit Path Environment Variable to add apache-maven-[version]\bin to ensure Powershell can access it.
  4. Open up Powershell. Navigate to whichever workspace folder your targeted STS project folder is stored in, then enter the following commands one by one and it will build your project!
  • cd C:\Java_Workspace\course-api-data
  • mvn -version
  • mvn clean install

I hope that this guide has proven helpful. It took me too long to be able to do this, but you can now do it easily! Thanks for reading.

Leave a comment

Design a site like this with WordPress.com
Get started