The Spring Boot Maven plugin is useful for repackaging a JAR that can be run via the command line using java.

Spring Boot Maven Plugin – overview

Spring Boot Maven Plugin – usage

Example:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${spring.boot.version}</version>
            <configuration>
                <mainClass>org.example.MainApp</mainClass>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Running:

java -Dspring.profiles.active=uat -Dparam.extra={val} -jar MainApp-1.0.jar

Resources profile structure can be kept simple:

  • application.properties
  • application-dev.properties
  • application-sandbox.properties
  • application-uat.properties
  • application-prod.properties

application.properties with a default profile for development purposes:

spring.profiles.active=dev

Leave a comment

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