Chapter 2. Configuring your application to use Spring Boot

Reference the Spring Boot BOM (Bill of Materials) artifact in the pom.xml file at the root directory of your application.

Prerequisites

  • A Maven-based application

Procedure

  1. Open the pom.xml file, add the me.snowdrop:spring-boot-bom artifact to the <dependencyManagement> section, and specify the <type>pom</type> and <scope>import</scope>:

    <project>
      ...
      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>me.snowdrop</groupId>
            <artifactId>spring-boot-bom</artifactId>
            <version>2.1.6.SP3-redhat-00001</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>
        </dependencies>
      </dependencyManagement>
      ...
    </project>
  2. Include the following properties to track the version of Spring Boot and the Spring Boot Maven Plugin you are using:

    <project>
      ...
      <properties>
        <spring-boot.version>2.1.6.RELEASE</spring-boot.version>
        <spring-boot-maven-plugin.version>2.1.6.RELEASE</spring-boot-maven-plugin.version>
      </properties>
      ...
    </project>
  3. Specify the repositories containing RHOAR Spring Boot Starters and the Spring Boot Maven Plugin:

      <!-- Specify the repositories containing RHOAR artifacts. -->
      <repositories>
        <repository>
          <id>redhat-ga</id>
          <name>Red Hat GA Repository</name>
          <url>https://maven.repository.redhat.com/ga/</url>
        </repository>
      </repositories>
    
      <!-- Specify the repositories containing the plugins used to execute the build of your application. -->
      <pluginRepositories>
        <pluginRepository>
          <id>redhat-ga</id>
          <name>Red Hat GA Repository</name>
          <url>https://maven.repository.redhat.com/ga/</url>
        </pluginRepository>
      </pluginRepositories>
  4. Reference spring-boot-maven-plugin as the plugin used to package your application:

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

Additional resources