简体   繁体   English

eclipse 插件中存在的“groovy-all”jar 与 maven 依赖项之间的兼容性问题

[英]Compatibility issue between the 'groovy-all' jars present in eclipse plugin and maven dependency

In my POM, there is a dependency: spock-core 1.0-groovy-2.3, which adds groovy-all 2.3.10 to my project.在我的 POM 中,有一个依赖项:spock-core 1.0-groovy-2.3,它将 groovy-all 2.3.10 添加到我的项目中。 And, my eclipse groovy plugin contains groovy-all 2.3.7 jar.而且,我的 eclipse groovy 插件包含 groovy-all 2.3.7 jar。 So, whenever I try to run my groovy spec file, following error is thrown:因此,每当我尝试运行我的 groovy 规范文件时,都会抛出以下错误:

groovy.lang.GroovyRuntimeException: Conflicting module versions. groovy.lang.GroovyRuntimeException:模块版本冲突。 Module [groovy-all is loaded in version 2.3.7 and you are trying to load version 2.3.10模块 [groovy-all 已在 2.3.7 版中加载,而您正在尝试加载 2.3.10 版

So, inorder to match the jars I am left with two options:所以,为了匹配罐子,我有两个选择:

  • Downgrade the version of spock-core dependency降级 spock-core 依赖的版本
  • Upgrade eclipse plugin groovy-all jar to 2.3.10将 eclipse 插件 groovy-all jar 升级到 2.3.10

First option is NOT possible as there is no such spock-core dependency which could provide me groovy-all 2.3.7 jar.第一个选项是不可能的,因为没有这样的 spock-core 依赖项可以为我提供 groovy-all 2.3.7 jar。 So, please guide me as how I should upgrade my groovy eclipse plugin from 2.3.7 to 2.3.10.所以,请指导我如何将我的 groovy eclipse 插件从 2.3.7 升级到 2.3.10。

PS I have set groovy compiler level as 2.3 for my project. PS我已经为我的项目设置了 groovy 编译器级别为 2.3。 And, I am facing the same issue on Luna, Kepler, Juno eclipse.而且,我在 Luna、Kepler、Juno eclipse 上也面临着同样的问题。

You can "downgrade" the Spock dependency.您可以“降级”Spock 依赖项。 Simply add an exclude of "groovy-all" to your Spock dependency.只需将“groovy-all”的排除项添加到您的 Spock 依赖项中即可。 Then explicitly add a dependency on groovy-all 2.3.7然后显式添加对 groovy-all 2.3.7 的依赖

The exclusion can be added as follows :可以按如下方式添加排除项:

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

Update your POM file by adding the below maven repos:通过添加以下 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM