Posts

Showing posts from July, 2023

How to create a Jar file from a Spring Boot Application using Maven

In this article, we will learn how to create a JAR file from a Spring Boot application using Maven. Introduction The spring-boot-maven-plugin allows packaging a Spring Boot application as a JAR/WAR file. It needs to be specified in the project  pom.xml along with the type of packaging ( jar / war ). Project Creation and Setup Step 1 – Let us use an existing project as a starting point. Clone the code from this Spring Boot Thymeleaf project. Step 2 – Update the pom.xml to specify the packaging and the `spring-boot-maven-plugin` configuration. So the pom file should look as follows: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.learnjava</groupId> <artifactId>learnjava-springbootthymeleaf-demo</artifactId>