1. Overview

In this article, We will learn about spring boot change jar name. While building spring boot application by default create jar file combination of <artifactId>-<version> for Maven and <baseName>-<version> for Gradle project. Here are different ways to change jar file name for Maven and Gradle in spring boot application.

2.1 Maven

2.1.1 Add <finalName> tag inside configuration (pom.xml)

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <finalName>spring-boot-new-jar-file-name</finalName>
                </configuration>
            </plugin>

2.1.2 Add <finalName> tag inside <build> (pom.xml)

     <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <finalName>spring-boot-new-jar-file-name</finalName>
    </build>

2.1.3 Add version in the file name (pom.xml)

<finalName>spring-boot-new-jar-file-name-${version}</finalName>

Do not add .jar at the end of file name. Plugin will automatically add .jar extenction.

2.2 Gradle

2.2.1 Add jar.archiveName inside build.gradle file. (build.gradle)

For Gradle add jar.archiveName with the new file name. Here need to add .jar extension at end of jar file name.

jar.archiveName="spring-boot-new-jar-file-name.jar"

2.2.2 Add version in a jar file name (build.gradle)

If requires application version at end of file then use jar.baseName. Here do not add .jar extension at end of jar file name.

jar.baseName="spring-boot-new-jar-file-name"

3. Conclusion

Here we learn how we can change jar file name while build Maven and Gradle application.

4. References

Was this post helpful?
Let us know, if you liked the post. Only in this way, we can improve us.
Yes
No
Tags: ,

Leave a Reply

Your email address will not be published. Required fields are marked *