bom .dom_MicroProfile 2.2 BOM导入支持

邢飞白
2023-12-01

bom .dom

MicroProfile 2.2刚刚发布,其中包含对Fault Tolerance,Open Tracing,Open API和Rest Client API的更新。 自2.2版以来,还支持使用BOM(物料清单)依赖项导入。

通过这种方法,我们可以在dependencyManagement块中定义MicroProfile版本,并仅使用所需的MicroProfile项目。 您使用运行时支持的MicroProfile版本,并将获得所有相应MicroProfile项目的正确版本。 与Java EE结合使用时也很有用。

请参见以下示例Maven POM:

<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>com.sebastian-daschner</groupId>
    <artifactId>bom-test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.eclipse.microprofile</groupId>
                <artifactId>microprofile</artifactId>
                <version>2.2</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.config</groupId>
            <artifactId>microprofile-config-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.fault-tolerance</groupId>
            <artifactId>microprofile-fault-tolerance-api</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>bom-test</finalName>
    </build>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

</project>

这将构建一个精简的部署工件,该工件仅提供已编译的类。 项目源代码是根据Java EE 8 API,MicroProfile Config 1.3和Fault Tolerance 2.0 API编译的。

翻译自: https://www.javacodegeeks.com/2019/02/microprofile-2-2-bom-support.html

bom .dom

 类似资料: