【问题标题】:Cannot use dependency jboss-javaee-6.0 in my Maven project无法在我的 Maven 项目中使用依赖项 jboss-javaee-6.0
【发布时间】:2013-04-24 09:53:02
【问题描述】:

我已经使用 JBoss 7.1.1 建立了一个 maven 项目,我想使用 JavaEE 库。 在我设置的根 pom.xml 中:

<repositories>
    <repository>
        <id>jboss</id>
        <url>https://repository.jboss.org/nexus/content/groups/public/</url>
    </repository>
</repositories>

我在根 pom.xml 和 ejb maven 模块的 pom.xml 中有这个:

<dependency>
        <groupId>org.jboss.spec</groupId>
        <artifactId>jboss-javaee-6.0</artifactId>
        <version>3.0.2.Final</version>
        <scope>provided</scope>
        <type>pom</type>
</dependency>

当我执行maven clean install 时,我收到此错误:

Failed to execute goal on project myproject-ejb: Could not resolve dependencies for project myproject:myproject-ejb:ejb:1.0-SNAPSHOT: Failure to find org.jboss.spec:jboss-javaee-6.0:jar:3.0.2.Final in https://repository.jboss.org/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of jboss has elapsed or updates are forced -> [Help 1]

我的配置怎么了?

编辑 1
如果我从根 pom.xml 中删除 jboss 存储库,我会收到此错误:

[ERROR] Failed to execute goal on project myproject-ejb: Could not resolve dependencies for project myproject:myproject-ejb:ejb:1.0-SNAPSHOT: The following artifacts could not be resolved: org.jboss.spec:jboss-javaee-6.0:jar:3.0.2.Final, xalan:xalan:jar:2.7.1.jbossorg-2: Could not find artifact org.jboss.spec:jboss-javaee-6.0:jar:3.0.2.Final in central (http://repo.maven.apache.org/maven2) -> [Help 1]

【问题讨论】:

    标签: maven ejb java-ee-6


    【解决方案1】:

    这是由 Xalan POM 文件中的 bug 引起的。以下workaround 为我解决了这个问题:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.spec</groupId>
                <artifactId>jboss-javaee-6.0</artifactId>
                <version>3.0.2.Final</version>
                <type>pom</type>
                <scope>provided</scope>
            </dependency>
            <!-- Required by jboss-javaee-6.0:3.0.2.Final (https://issues.jboss.org/browse/JBBUILD-708) --> 
            <dependency>
                <groupId>xalan</groupId>
                <artifactId>xalan</artifactId>
                <version>2.7.1</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    

    【讨论】:

    【解决方案2】:

    jboss-javaee-6.0 的给定依赖项可从Maven Central 获得,因此无需提供单独的存储库。

    根据错误消息,您需要从位置 maven 存储库(通常在 $HOME/.m2/repository 中)中删除特定位置,在这种情况下是文件夹 org/jboss/。之后你需要重建你的项目。

    【讨论】:

    • 我试图删除 jboss 存储库,但又遇到了另一个错误。请参阅上面的EDIT 1。我还删除了 .m2/repository 并重建了项目。
    • 您使用了错误的类型 org.jboss.spec:jboss-javaee-6.0:jar:3.0.2.Final 这引用了一个并非如此的 jar 文件。您需要在依赖项中引用 pom 工件(类型 pom)。
    【解决方案3】:

    这对我有用:

    <dependency>
        <groupId>org.jboss.spec</groupId>
        <artifactId>jboss-javaee-all-6.0</artifactId>
        <version>3.0.2.Final</version>
        <scope>provided</scope>
    </dependency>
    

    但我看到here 类似以下的方法也可能有效:

    <dependency>    
        <groupId>org.jboss.spec</groupId>
        <artifactId>jboss-javaee-web-6.0</artifactId>
        <version>2.0.0.Final</version>
        <type>pom</type>
        <scope>import</scope>    
    </dependency>
    

    【讨论】:

      猜你喜欢
      • 2012-01-26
      • 2012-09-06
      • 2011-12-01
      • 2020-09-22
      • 1970-01-01
      • 2022-11-27
      • 2012-04-21
      • 1970-01-01
      • 2017-02-14
      相关资源
      最近更新 更多