eclipse Groovy/Grails - 无法解析类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6167950/
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
Groovy/Grails - Unable to Resolve Class
提问by skaz
I am trying to build a Grails project in STS and am getting many error messages of the form: Groovy:unable to resolve class org.codehaus.groovy.grails.commons.ConfigurationHolder
as well as others like Groovy:unable to resolve class org.grails.plugins.springsecurity.service.AuthenticateService
. I have Grails 1.3.7 selected in the Project Properties, but I don't see an item for 'Grails Depedencies' like I do when I create a sample project. Is this the problem? How can I add it back in?
我正在尝试在 STS 中构建一个 Grails 项目,并且收到了许多以下形式的错误消息:Groovy:unable to resolve class org.codehaus.groovy.grails.commons.ConfigurationHolder
以及其他类似Groovy:unable to resolve class org.grails.plugins.springsecurity.service.AuthenticateService
. 我在“项目属性”中选择了 Grails 1.3.7,但我没有像创建示例项目时那样看到“Grails Depedencies”项。这是问题吗?我怎样才能把它加回来?
回答by skaz
I don't know why, but here are the steps I took to solve the problem:
我不知道为什么,但这是我为解决问题而采取的步骤:
- Right click on the project and go to Grails Tools -> Enable Dependency Management
- Grails Tools -> Refresh Dependencies. This correctly added the 'Grails Dependencies' library.
- I still had plugin errors. I for some reason had to uninstall them and then reinstall them for the project to realize they were there.
- 右键单击项目并转到 Grails 工具 -> 启用依赖项管理
- Grails 工具 -> 刷新依赖项。这正确添加了“Grails 依赖项”库。
- 我仍然有插件错误。由于某种原因,我不得不卸载它们,然后为项目重新安装它们以意识到它们在那里。
回答by biniam
For anyone who is using Grails >= 2.4
对于使用 Grails >= 2.4 的任何人
If you are using Grails 2.4 and above, use grails.util.Holders
instead of org.codehaus.groovy.grails.commons.ConfigurationHolder
.
如果您使用的是 Grails 2.4 及更高版本,请使用grails.util.Holders
代替org.codehaus.groovy.grails.commons.ConfigurationHolder
。
Read the doc heresection 'Static Holder'
在此处阅读文档部分“静态支架”
Classes The following deprecated classes have been removed from Grails 2.4.x:
org.codehaus.groovy.grails.commons.ApplicationHolder org.codehaus.groovy.grails.commons.ConfigurationHolder org.codehaus.groovy.grails.plugins.PluginManagerHolder org.codehaus.groovy.grails.web.context.ServletContextHolder org.codehaus.groovy.grails.compiler.support.GrailsResourceLoaderHolder If you or any plugins you have installed are using these classes you will get a compilation error. The problem can be rectified by updating to new plugins and using grails.util.Holders instead.
类 以下已弃用的类已从 Grails 2.4.x 中删除:
org.codehaus.groovy.grails.commons.ApplicationHolder org.codehaus.groovy.grails.commons.ConfigurationHolder org.codehaus.groovy.grails.plugins.PluginManagerHolder org.codehaus.groovy.grails.web.context.ServletContextHolder org.codehaus。 groovy.grails.compiler.support.GrailsResourceLoaderHolder 如果您或您安装的任何插件正在使用这些类,您将收到编译错误。可以通过更新到新插件并改用 grails.util.Holders 来纠正该问题。
回答by Jim Norman
If "Refresh Dependencies" has done all it can for you (as you indicate in your comment on the question), try disabling and re-enabling dependencies. You might try refreshing dependencies again afterward if the Acegi plugin still isn't recognized.
如果“刷新依赖项”已经为您完成了它所能做的一切(正如您在对问题的评论中所指出的那样),请尝试禁用和重新启用依赖项。如果仍然无法识别 Acegi 插件,您可以稍后再次尝试刷新依赖项。
回答by SShehab
there is another way solved me this issue when i moved my workspace from Windows OS to Ubuntu , go to
当我将工作区从 Windows 操作系统移到 Ubuntu 时,还有另一种方法解决了这个问题,请转到
yourWorkSpace -->yourGrailsProject-->setting folder --> org.grails.ide.eclipse.core.prefs,
then check all the grails paths are correct or not , because in my case all were pointing to windows paths ..
然后检查所有 grails 路径是否正确,因为在我的情况下,所有路径都指向 Windows 路径..
Hope this solve.
希望这能解决。
回答by nshweta
I faced a similar issue: "Unable to resolve class GrailsTestCase". I checked Grails Tools of my project and observed Dependency Management was already enabled (IDE - GGTS). I just disabled Dependency Management, refreshed and enabled it again. This solved the issue for me.
我遇到了类似的问题:“无法解析 GrailsTestCase 类”。我检查了我的项目的 Grails 工具并观察到依赖管理已经启用(IDE - GGTS)。我刚刚禁用了依赖管理,刷新并再次启用它。这为我解决了这个问题。