依赖项的版本号在哪里

时间:2014-09-25 05:20:36

标签: maven dependencies

我之前问了一个类似的问题,关于通过父pom继承依赖版本号的方法,我得到了那个部分。但是现在我看到了一个类似的POM,并且无法提供这些依赖项的版本号。如您所见,所有依赖项都没有指定版本号,父POM也没有提供这些版本号。

请帮助了解其工作原理。非常感谢。

<?xml version="1.0"?>
<!--
JBoss, Home of Professional Open Source
Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
contributors by the @authors tag. See the copyright.txt in the
distribution for a full listing of individual contributors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.wildfly.quickstarts</groupId>
    <artifactId>wildfly-quickstarts-parent</artifactId>
    <version>8.0.0-SNAPSHOT</version>
    <relativePath>../pom.xml</relativePath>
</parent>

<artifactId>wildfly-greeter</artifactId>
<packaging>war</packaging>
<name>WildFly Quickstarts: Greeter</name>
<description>WildFly Quickstarts: Greeter</description>

<url>http://wildfly.org</url>
<licenses>
    <license>
        <name>Apache License, Version 2.0</name>
        <distribution>repo</distribution>
        <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
    </license>
</licenses>


<dependencyManagement>
    <dependencies>
        <!-- Define the version of JBoss' Java EE 7 APIs we want to import.
           Any dependencies from org.jboss.spec will have their version defined by this
           BOM -->
        <!-- JBoss distributes a complete set of Java EE 7 APIs including
           a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or
           a collection) of artifacts. We use this here so that we always get the correct
           versions of artifacts. Here we use the jboss-javaee-7.0 stack (you can
           read this as the JBoss stack of the Java EE 7 APIs). You can actually
           use this stack with any version of WildFly that implements Java EE 7, not
           just WildFly 8! -->
        <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-7.0</artifactId>
            <version>${version.jboss.spec.javaee.7.0}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>

    <!-- Import the CDI API, we use provided scope as the API is included in JBoss WildFly -->
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Import the Common Annotations API (JSR-250), we use provided scope 
       as the API is included in JBoss WildFly -->
    <dependency>
        <groupId>org.jboss.spec.javax.annotation</groupId>
        <artifactId>jboss-annotations-api_1.2_spec</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Import the JSF API, we use provided scope as the API is included in JBoss WildFly -->
    <dependency>
        <groupId>org.jboss.spec.javax.faces</groupId>
        <artifactId>jboss-jsf-api_2.2_spec</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Import the JPA API, we use provided scope as the API is included in JBoss WildFly -->
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.1-api</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Import the JPA API, we use provided scope as the API is included in JBoss WildFly -->
    <dependency>
        <groupId>org.jboss.spec.javax.transaction</groupId>
        <artifactId>jboss-transaction-api_1.2_spec</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Import the EJB API, we use provided scope as the API is included in JBoss WildFly -->
    <dependency>
        <groupId>org.jboss.spec.javax.ejb</groupId>
        <artifactId>jboss-ejb-api_3.2_spec</artifactId>
        <scope>provided</scope>
    </dependency>

</dependencies>

<build>
    <!-- Set the name of the war, used as the context root when the app 
       is deployed -->
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <!-- WildFly plugin to deploy war -->
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>${version.wildfly.maven.plugin}</version>
            <configuration>
                <skip>false</skip>
            </configuration>
        </plugin>

    </plugins>
</build>

1 个答案:

答案 0 :(得分:0)

在maven中,可以在<dependencyManagement>标记中管理依赖项版本。

在您的情况下,使用以下

管理版本
<dependency>
   <groupId>org.jboss.spec</groupId>
   <artifactId>jboss-javaee-7.0</artifactId>
   <version>${version.jboss.spec.javaee.7.0}</version>
   <type>pom</type>
   <scope>import</scope>
</dependency>

在上面的标记中,范围是导入,这意味着将导入pom,因此依赖项版本在org.jboss.spec:jboss-javaee-7.0工件中维护。它在标签上方的注释中提到。

REF:jboss-javaee-7.0-1.0.1.Final.pom