Este contenido no está disponible en el idioma seleccionado.

Chapter 4. Develop MicroProfile applications for JBoss EAP


To get started with developing applications that use MicroProfile APIs, create a Maven project and define the required dependencies. Use the JBoss EAP MicroProfile Bill of Materials (BOM) to control the versions of runtime Maven dependencies in the application Project Object Model (POM).

After you create a Maven project, refer to the JBoss EAP XP Quickstarts for information about developing applications for specific MicroProfile APIs. For more information, see JBoss EAP XP Quickstarts.

4.1. Creating a Maven project with maven-archetype-webapp

Use the maven-archetype-webapp archetype to create a Maven project for building applications for JBoss EAP deployment. Maven provides different archetypes for creating projects based on templates specific to project types. The maven-archetype-webapp creates a project with the structure required to develop simple web-applications.

Prerequisites

Procedure

  1. Set up a Maven project by using the mvn command. The command creates the directory structure for the project and the pom.xml configuration file.

    $ mvn archetype:generate                       \
    -DgroupId=<group_id>                           \
    1
    
    -DartifactId=<artifact_id>                     \
    2
    
    -DarchetypeGroupId=org.apache.maven.archetypes \
    3
    
    -DarchetypeArtifactId=maven-archetype-webapp   \
    4
    
    -DinteractiveMode=false                         
    5
    1
    groupID uniquely identifies the project.
    2
    artifactID is the name for the generated jar archive.
    3
    archetypeGroupID is the unique ID for maven-archetype-webapp.
    4
    archetypeArtifactId is the artifact ID for maven-archetype-webapp.
    5
    InteractiveMode instructs Maven to use the supplied parameters rather than starting in interactive mode.
  2. Navigate to the generated directory.
  3. Open the generated pom.xml configuration file in a text editor.
  4. Remove the content inside the <project> section of the pom.xml configuration file after the <name>helloworld Maven Webapp</name> line.

    Ensure that the file looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>${group_id}</groupId>
        <artifactId>${artifact_id}</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>war</packaging>
        <name>${artifact_id} Maven Webapp</name>
    
    </project>

    The content was removed because it is not required for the application.

4.2. Defining properties in a Maven project

You can define properties in a Maven pom.xml configuration file as place holders for values. By default, the archetype updates some of the properties it creates

Prerequisites

Procedure

  • Update the properties to match the following.

    <project>
        ...
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <!-- the Maven project should use the minimum Java SE version supported -->
            <maven.compiler.release>17</maven.compiler.release>
        </properties>
    </project>

4.3. Defining the repositories in a Maven project

Define the artifact and plug-in repositories in which Maven looks for artifacts and plug-ins to download.

Prerequisites

Procedure

  1. Define the artifacts repository.

    <project>
        ...
        <repositories>
            <repository>                                                                
    1
    
                <id>jboss-public-maven-repository</id>
                <name>JBoss Public Maven Repository</name>
                <url>https://repository.jboss.org/nexus/content/groups/public/</url>
                <releases>
                    <enabled>true</enabled>
                    <updatePolicy>never</updatePolicy>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>never</updatePolicy>
                </snapshots>
                <layout>default</layout>
            </repository>
            <repository>                                                                
    2
    
                <id>redhat-ga-maven-repository</id>
                <name>Red Hat GA Maven Repository</name>
                <url>https://maven.repository.redhat.com/ga/</url>
                <releases>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>never</updatePolicy>
                </snapshots>
                <layout>default</layout>
            </repository>
        </repositories>
    </project>
    1
    The Red Hat GA Maven repository provides all the productized JBoss EAP and other Red Hat artifacts.
    2
    The JBoss Public Maven Repository provides artifacts such as WildFly Maven plug-ins
  2. Define the plug-ins repository.

    <project>
        ...
        <pluginRepositories>
            <pluginRepository>
                <id>jboss-public-maven-repository</id>
                <name>JBoss Public Maven Repository</name>
                <url>https://repository.jboss.org/nexus/content/groups/public/</url>
                <releases>
                   <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
            <pluginRepository>
                <id>redhat-ga-maven-repository</id>
                <name>Red Hat GA Maven Repository</name>
                <url>https://maven.repository.redhat.com/ga/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </project>

Import the JBoss EAP Expansion Bill of Materials (BOM) to control the versions of runtime Maven dependencies. When you specify a BOM in the <dependencyManagement> section, you do not need to individually specify the versions of the Maven dependencies defined in the provided scope.

Prerequisites

Procedure

  1. Add a property for the BOM version in the properties section of the pom.xml configuration file.

    <properties>
        ...
        <version.bom.expansion>6.0.0.GA-redhat-00011</version.bom.expansion>
    </properties>

    The value defined in the property <version.bom.expansion> is used as the value for the BOM version.

  2. Import the JBoss EAP BOMs dependency management.

    <project>
        ...
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.bom</groupId>                   
    1
    
                    <artifactId>jboss-eap-expansion</artifactId> 
    2
    
                    <version>${version.bom.expansion}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    </project>
    1
    groupID of the JBoss EAP-provided BOM.
    2
    artifactID of the JBoss EAP-provided BOM that provides supported JBoss EAP Expansion APIs.

Optionally, you can import the JBoss EAP EE with Tools Bill to your project. For more information, see Importing the JBoss EAP BOMs as dependency management in a Maven project.

You can optionally import the JBoss EAP EE With Tools Bill of materials (BOM). The JBoss EAP BOM provides supported JBoss EAP Java EE APIs plus additional JBoss EAP API JARs and client BOMs. You only need to import this BOM if your application requires Jakarta EE APIs in addition to the Microprofile APIs.

Prerequisites

Procedure

  1. Add a property for the BOM version in the properties section of the pom.xml configuration file.

    <properties>
        ....
        <version.bom.ee>8.1.0.GA-redhat-0001</version.bom.ee>
    </properties>
  2. Import the JBoss EAP BOMs dependency management.

    <project>
        ...
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.bom</groupId>                 
    1
    
                    <artifactId>jboss-eap-ee-with-tools</artifactId> 
    2
    
                    <version>${version.bom.ee}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    </project>
    1
    groupID of the JBoss EAP-provided BOM.
    2
    artifactID of the JBoss EAP-provided BOM that provides supported JBoss EAP Java EE APIs plus additional JBoss EAP API JARs and client BOMs, and development tools such as Arquillian.

4.6. Adding plug-in management in a Maven project

Add Maven plug-in management section to the pom.xml configuration file to get plug-ins required for Maven CLI commands.

Prerequisites

Procedure

  1. Define the versions for wildfly-maven-plugin, in the <properties> section.

    <properties>
        ...
        <version.plugin.wildfly>5.1.1.Final</version.plugin.wildfly>
        <version.plugin.war>3.3.2</version.plugin.war>
    </properties>
  2. Add <pluginManagement> in <build> section inside the <project> section.

    <project>
        ...
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>    
    1
    
                        <groupId>org.wildfly.plugins</groupId>
                        <artifactId>wildfly-maven-plugin</artifactId>
                        <version>${version.plugin.wildfly}</version>
                    </plugin>
                    <plugin>                                  
    2
    
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>${version.plugin.war}</version>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
    </project>
    1
    You can use the wildfly-maven-plugin to deploy an application to JBoss EAP using the wildfly:deploy command.
    2
    You need to manage the war plugin version to ensure compatibility with JDK17+.

4.7. Verifying a maven project

Verify that the Maven project you configured builds.

Prerequisites

Procedure

  • Install the Maven dependencies added in the pom.xml locally.

    $ mvn package

    You get an output similar to the following:

    ...
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    ...

For more information about developing applications for specific MicroProfile APIs, see JBoss EAP XP Quickstarts.

Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2026 Red Hat
Volver arriba