第 4 章 通过配置 pom.xml 文件来创建 Quarkus 项目


您可以通过配置 Maven POM XML 文件来创建 Quarkus 项目。

流程

  1. 在文本编辑器中打开 pom.xml 文件。
  2. 添加包含以下内容的配置属性:

    • Quarkus Maven 插件的版本
    • Quarkus BOM 的 groupIDartifactID 和版本
    • Maven Surefire 插件的版本
    <properties>
        <quarkus-plugin.version>1.11.7.Final-redhat-00009</quarkus-plugin.version>
        <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
        <quarkus.platform.group-id>com.redhat.quarkus</quarkus.platform.group-id>
        <quarkus.platform.version>1.11.7.Final-redhat-00009</quarkus.platform.version>
        <surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
    </properties>
    Copy to Clipboard Toggle word wrap
  3. 添加 Quarkus GAV(组、工件和版本),并使用 quarkus-universe-bom 文件省略不同 Quarkus 依赖项的版本:

    <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>${quarkus.platform.group-id}</groupId>
            <artifactId>${quarkus.platform.artifact-id}</artifactId>
            <version>${quarkus.platform.version}</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>
        </dependencies>
      </dependencyManagement>
    Copy to Clipboard Toggle word wrap
  4. 添加 Quarkus Maven 插件:

    <build>
        <plugins>
            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus.platform.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    Copy to Clipboard Toggle word wrap
  5. 可选: 要构建原生应用程序,请添加特定的原生配置集,其包含 Maven Surefire 和 Maven Failsafe 插件并启用 原生 软件包类型:

    <profiles>
        <profile>
            <id>native</id>
            <properties>
                <quarkus.package.type>native</quarkus.package.type>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>${surefire-plugin.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                                <configuration>
                                    <systemProperties>
                                        <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                                    </systemProperties>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    Copy to Clipboard Toggle word wrap

    在其名称中包含 IT 的测试已注释 @NativeImageTest 对原生可执行文件运行。

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部