Spring Boot -How to change Spring Boot application jar name based on Build Environment QA or PROD

3.4k Views Asked by At

I am developing a spring boot application in that am using application.yml configuration for Three different environment PROD/DEV/STAGE

am using maven to build as executable jar i need help in when am building

  • for DEV environment the jar name should be abc-dev.jar
  • for PROD environment the jar name should be abc-PROD.jar

am using mvn package -Dspring.profiles.active=dev

for building the application

how can i pick the application name dynamically and update in pom.xml file

1

There are 1 best solutions below

2
On BEST ANSWER

Try something like this in your pom.xml

<packaging>jar</packaging> <build> <finalName>abc-${spring.profiles.active}</finalName> </build>

This should work for Maven version >= 3