eclipse Grails / Groovy / GGTS:run-app 上的模块版本冲突
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15079286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Grails / Groovy / GGTS: Conflicting module versions on run-app
提问by digitalbreed
After upgrading a Grails application from 2.2.0 to 2.2.1 I keep getting the following error when attempting to debug a Grails application from GGTS via Debug as... -> Grails Command (run-app):
将 Grails 应用程序从 2.2.0 升级到 2.2.1 后,当我尝试通过 Debug as... -> Grails Command (run-app) 从 GGTS 调试 Grails 应用程序时,我不断收到以下错误:
Error starting Grails: nulljava.lang.ExceptionInInitializerError
at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:62)
at groovy.lang.GroovyObjectSupport.<init>(GroovyObjectSupport.java:32)
at groovy.lang.Closure.<init>(Closure.java:221)
at groovy.lang.Closure.<init>(Closure.java:238)
at groovy.lang.Closure.<init>(Closure.java:205)
at groovy.lang.Closure.<clinit>(Closure.java:205)
at org.codehaus.groovy.grails.cli.GrailsScriptRunner.<clinit>(GrailsScriptRunner.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.groovy.grails.cli.support.GrailsStarter.rootLoader(GrailsStarter.java:234)
at org.codehaus.groovy.grails.cli.support.GrailsStarter.main(GrailsStarter.java:262)
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.0.5 and you are trying to load version 2.0.7
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerExtensionModuleFromProperties(MetaClassRegistryImpl.java:186)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerExtensionModuleFromMetaInf(MetaClassRegistryImpl.java:174)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerClasspathModules(MetaClassRegistryImpl.java:156)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:111)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:73)
at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:33)
... 14 more
I'm running GGTS 3.1.0.RELEASE with the Groovy Compiler 2.0 Feature 2.7.1.xx-20120921-2000-e42RELEASE and Groovy/Grails Tool Suite 3.1.0.201210061306-RELEASE-e42. The project has configured Groovy Compiler level 2.0. Eclipse Preferences say "You are currently using Groovy Compiler version 2.0.4.xx-20120921-2000-e42RELEASE".
我正在使用 Groovy Compiler 2.0 Feature 2.7.1.xx-20120921-2000-e42RELEASE 和 Groovy/Grails Tool Suite 3.1.0.201210061306-RELEASE-e42 运行 GGTS 3.1.0.RELEASE。该项目已配置 Groovy Compiler level 2.0。Eclipse 首选项显示“您当前使用的是 Groovy 编译器版本 2.0.4.xx-20120921-2000-e42RELEASE”。
Any hints?
任何提示?
采纳答案by digitalbreed
I have no explanation why it didn't work, but I found a workaround.
我不知道为什么它不起作用,但我找到了一个解决方法。
I had another run target configured for the same app, but with a -Dgrails.env=...
setting, which I could launch without problems. I simply copied this config and removed the parameter. That way, I basically recreated the simple launch config which previously kept failing.
我为同一个应用程序配置了另一个运行目标,但有一个-Dgrails.env=...
设置,我可以毫无问题地启动它。我只是复制了这个配置并删除了参数。这样,我基本上重新创建了以前一直失败的简单启动配置。
Problem gone.
问题没了。
回答by SShehab
i had this problem on Grails 2.2.0 on Ubuntu machine , i fixed it with the below steps :
我在 Ubuntu 机器上的 Grails 2.2.0 上遇到了这个问题,我通过以下步骤修复了它:
- open eclipse go to "Run as" the "Run Configurations"
- choose "Environment" tab , then choose "replace native environment with specified environment "
- 打开 eclipse 转到“Run as”“Run Configurations”
- 选择“环境”选项卡,然后选择“用指定的环境替换本机环境”
that solved the problem for me .. hope this help
为我解决了这个问题..希望这有帮助
回答by lance-java
I had the same problem, I was picking up groovy-all 2.0.7 from GGTS and 2.0.8 from my grails project. To resolve the problem I removed the "Groovy Dependencies" library from the eclipse project.
我遇到了同样的问题,我从 GGTS 中获取了 groovy-all 2.0.7,从我的 grails 项目中获取了 2.0.8。为了解决这个问题,我从 eclipse 项目中删除了“Groovy Dependencies”库。
Right click on project -> Properties -> Java Build Path -> Libraries (tab) -> Groovy Dependencies -> Remove
右键单击项目-> 属性-> Java 构建路径-> 库(选项卡)-> Groovy 依赖项-> 删除
回答by Nathan Ward
Manually delete the run-app Run Configuration so it gets recreated. This was reported as a bug on Aug. 1st, 2013. Bug report: https://issuetracker.springsource.com/browse/STS-3501
手动删除 run-app 运行配置,以便重新创建。这在 2013 年 8 月 1 日被报告为一个错误。错误报告:https: //issuetracker.springsource.com/browse/STS-3501
回答by Wisnu Manupraba
I deleted .metadata in GGTS workspace and reimport project. It works, I can run-app again.
我删除了 GGTS 工作区中的 .metadata 并重新导入项目。它有效,我可以再次运行应用程序。
回答by stenix
I had the same problem and i solved it by:
我遇到了同样的问题,我通过以下方式解决了它:
- For your project: Open Run As->Run Configurations
- Go to the Refresh tab
- Check the Refresh resources upon completion
- Press Run
- 对于您的项目:打开运行方式->运行配置
- 转到刷新选项卡
- 完成后检查刷新资源
- 按运行
That did the trick for me.
这对我有用。
回答by f1v3
I solved it by removing the option to manually load the classpath in Run Configuration. It was using the wrong Grails version (2.5.0 instead of 2.5.1).
我通过删除在运行配置中手动加载类路径的选项来解决它。它使用了错误的 Grails 版本(2.5.0 而不是 2.5.1)。
Basically the wrong classpath was used.
基本上使用了错误的类路径。
Maybe this brings someone on the correct path :)
也许这会让某人走上正确的道路:)
回答by Anton Krosnev
I had the same exception, when I was trying to run JUnit tests on my Spring boot project in Eclipse only, mvn executes them fine. I'm not using Gradle or Groovy. Indeed checking the test's class path upon debug, showed two versions of groovy.jar. The work version of the groovy.jar was picked from other projects in the Eclipse workspace. I was able to fix it by removing Resolve dependencies from Workspace projectsin project properties -> Maven
我有同样的例外,当我试图仅在 Eclipse 中对我的 Spring boot 项目运行 JUnit 测试时,mvn 可以很好地执行它们。我没有使用Gradle 或 Groovy。确实在调试时检查测试的类路径,显示了两个版本的 groovy.jar。groovy.jar 的工作版本是从 Eclipse 工作区中的其他项目中挑选出来的。我能够通过从项目属性 -> Maven 中的工作区项目中删除解决依赖项来修复它
回答by Sishi Ye
use mvn denpendency:tree to check your dependencies, maybe there exist version conflicts.
使用 mvn denpendency:tree 检查您的依赖项,可能存在版本冲突。
回答by geneSummons
I know this is a GGTS question, but Google led me here and this seems to be a common issue even after several years so I'm posting this answer here. Hopefully it can help other STS users who also land here.
我知道这是一个 GGTS 问题,但谷歌将我带到这里,即使经过几年,这似乎也是一个常见问题,所以我在这里发布了这个答案。希望它可以帮助其他也登陆这里的 STS 用户。
I had this problem with Spring Tool Suite, using Spring Boot Version 1.3.3.RELEASE and gradle version 2.14. There is some internal dependency on groovy 2.4.6 and groovy-all 2.4.6, but my Eclipse workspace Groovy Libraries are version 2.4.7. Removing the Groovy Libraries from the Spring/Gradle project properties(s) works for running those projects, but for other Groovy projects in the workspace you are stuck between a rock and a hard place. They will either run if you click yes when "Errors exist in project. Run anyway?" if you remove the Groovy libs from the properties build path, or they will not have project errors if you put the Groovy libs in the properties build path.
我在使用 Spring Boot 版本 1.3.3.RELEASE 和 gradle 版本 2.14 时遇到了 Spring Tool Suite 这个问题。对 groovy 2.4.6 和 groovy-all 2.4.6 有一些内部依赖性,但我的 Eclipse 工作区 Groovy 库是 2.4.7 版。从 Spring/Gradle 项目属性中删除 Groovy 库适用于运行这些项目,但对于工作区中的其他 Groovy 项目,您会陷入困境。如果您在“项目中存在错误。仍然运行?”时单击“是”,它们将运行。如果您从属性构建路径中删除 Groovy 库,或者如果您将 Groovy 库放在属性构建路径中,它们将不会有项目错误。
Resolved by adding explicit dependencies in build.gradle on groovy 2.4.7 and groovy-all 2.4.7 for Gradle projects in the workspace
通过在 groovy 2.4.7 和 groovy-all 2.4.7 的 build.gradle 中为工作区中的 Gradle 项目添加显式依赖项来解决
compile('org.codehaus.groovy:groovy:2.4.7')
compile('org.codehaus.groovy:groovy-all:2.4.7')
and (close Eclipse STS) then removing the 2.4.6 folder(s) from the .gradle cache
和(关闭 Eclipse STS)然后从 .gradle 缓存中删除 2.4.6 文件夹
<path to>\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy.4.6
<path to>\.gradle\caches\modules-2\files-2.1\org.codehaus.groovy\groovy-all.4.6
and (Open STS) then right-click gradle project(s)>gradle>refresh gradle project
和(打开 STS)然后右键单击 gradle project(s)>gradle>refresh gradle project
Now other Groovy projects in the workspace run without the 2.4.6 vs 2.4.7 conflict.
现在工作区中的其他 Groovy 项目运行时不会出现 2.4.6 与 2.4.7 冲突。
回答by Joshua Goldberg
Another solution worked for me when Eclipse stopped being able to run my project with the "groovy-all is loaded in version ... and you are trying to load version" error.
当 Eclipse 停止运行我的项目时,另一个解决方案对我有用,并且出现“groovy-all 已加载到版本中......而您正在尝试加载版本”错误。
Manually removing a groovy-all line from the .classpath fixed it.
从 .classpath 中手动删除 groovy-all 行修复了它。
<classpathentry kind="lib" path="Libraries/groovy-all-2.1.2.jar"/>
I found the solution in this blog post.
我在这篇博文中找到了解决方案。