【问题标题】:Compatibility issue between the 'groovy-all' jars present in eclipse plugin and maven dependencyeclipse 插件中存在的“groovy-all”jar 与 maven 依赖项之间的兼容性问题
【发布时间】:2015-03-18 07:13:59
【问题描述】:

在我的 POM 中,有一个依赖项:spock-core 1.0-groovy-2.3,它将 groovy-all 2.3.10 添加到我的项目中。而且,我的 eclipse groovy 插件包含 groovy-all 2.3.7 jar。因此,每当我尝试运行我的 groovy 规范文件时,都会引发以下错误:

groovy.lang.GroovyRuntimeException:模块版本冲突。模块 [groovy-all 在 2.3.7 版本中加载,您正在尝试加载 2.3.10 版本

所以,为了匹配罐子,我有两个选择:

  • 降级 spock-core 依赖的版本
  • 将eclipse插件groovy-all jar升级到2.3.10

第一个选项是不可能的,因为没有这样的 spock-core 依赖项可以为我提供 groovy-all 2.3.7 jar。所以,请指导我如何将我的 groovy eclipse 插件从 2.3.7 升级到 2.3.10。

P.S. 我已将我的项目的 groovy 编译器级别设置为 2.3。而且,我在 Luna、Kepler、Juno eclipse 上面临同样的问题。

【问题讨论】:

  • 您的 Eclipse 项目是否包含 Groovy Libraries 类路径容器(eclipse 插件 groovy-all jar 的源代码)?如果 Maven Dependencies 容器是您获取 groovy-all 和 spock-core 的位置,则可以从您的项目中删除它。

标签: java eclipse maven groovy


【解决方案1】:

您可以“降级”Spock 依赖项。只需将“groovy-all”排除在您的 Spock 依赖项中即可。然后显式添加对 groovy-all 2.3.7 的依赖

排除可以添加为follows:

<dependency>
    ...
    <exclusions>
        <exclusion>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
        </exclusion>
    </exclusions>
    ...
</dependency>

【讨论】:

    【解决方案2】:

    通过添加以下 maven 存储库来更新您的 POM 文件:

    <!-- Below 3 GROOVY dependencies are MUST to waive the version conflict in runtime
             https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
            <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-all</artifactId>
                <version>2.4.16</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-xml -->
            <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-xml</artifactId>
                <version>2.4.16</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy -->
            <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy</artifactId>
                <version>2.4.16</version>
            </dependency>
    

    【讨论】:

    • 看到需要的版本出现在控制台上。然后在谷歌上搜索 mvn repo 上的这些版本。我的情况是 2.4.16 是冲突并手动添加了这些版本。问题已解决!
    猜你喜欢
    • 2013-07-19
    • 2015-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多