Shiro-quick-start 的 Grails 问题:导入无法解决(通过 Eclipse)
在我的新 grails 项目中,我安装了 shiro (grails install-plugin shiro
) 以及快速设置grails shiro-quick-start
。这会生成新文件,如 shiro 文档n 中所述。
然而,在其中一个文件 controllers/(default package)AuthController.groovy
中,有 8 个被 eclipse (SpringSource Tools Suite) 标记的问题。其中五个问题分别解决了五个导入:
Groovy:unable to resolve class org.apache.shiro.authc.AuthenticationException
…
指定正确的包并将文件移动到该包并不能解决问题。其他三个问题标记是:
Groovy:Catch statement parameter type is not a subclass of Throwable.
(x3) 我想这个问题可能与导入失败有关,因此一旦解决了前一个问题就可能消失。
现在,我可以自己设置 shiro没有快速启动,但说实话,我更愿意坚持快速启动并对其进行扩展,如指南中所述。
(显而易见)问题 1:有人知道为什么 Eclipse 会给我这些错误消息吗?我是否错过了安装过程中的某个步骤?
(不太重要)问题2:我尝试应用修复(默认包)问题,却发现_ShiroInternal.groovy的相关部分已经存在对包路径的引用。为什么它仍然安装到默认目录?这可能与我的问题有关吗?
额外的奇怪之处:还有另一个文件 realm/ShiroDbRealm.groovy
,其中包含 org.apache.shiro
资源的导入。 Eclipse 中没有包声明,也没有错误标记。一旦我添加了项目的正确包声明并将文件移动到该包,导入就无法再解析。这可能是这里发生的事情的线索。
On my fresh new grails project, I installed shiro
(grails install-plugin shiro
)
and the quick setup grails shiro-quick-start
. This generated new files as described in the shiro documentation.
However, in one of those files, controllers/(default package)AuthController.groovy
there are eight problem marked by eclipse (SpringSource Tools Suite). Five of those problems address the five imports respectively:
Groovy:unable to resolve class org.apache.shiro.authc.AuthenticationException
…
Specifying the correct package and moving the file to that package doesn’t solve the problem. The three other problem markers are:
Groovy:Catch statement parameter type is not a subclass of Throwable.
(x3)
I suppose this problem might be related to the failed imports and might thus vanish once the previous problem is resolved.
Now, I could set up shiro myself without the quick start, but tbh I’d prefer to stick with the quick start and expand on that, as described in the guide.
(obvious) Question 1: Does anybody have an idea as to why Eclipse gives me those error messages? Did I miss a step in the installation process?
(not so important) Question 2: I tried to apply the fix to the (default package) issue, only to find that there is already a reference to the package path at the relevant part of _ShiroInternal.groovy. Why does it still install to default directory? Might this be related to my problem?
Additional oddity: There is another file, realm/ShiroDbRealm.groovy
, that includes imports of org.apache.shiro
resources. There is no package declaration and there are no error markers in Eclipse. Once I add the correct package declaration of my project and move the file to that package, imports cannot be resolved anymore. This might be a clue to what is happening here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须将 shiro 库 jar 添加到 eclipse 项目构建路径。
这些库(在我的例子中)默认安装到我的主文件夹中的 grails 项目插件目录中。
You have to add the shiro library jars to the eclipse project build path.
The librarys (in my case) are by default installed to the grails project plugin directory in my home folder.
也许一个更简单的修复,解决了我遇到的问题:
无论您是否已经通过其他方式安装了它,请运行:
虽然这可能会告诉您该插件已经安装,但这也会为您整理路径,这应该可以解决问题。
Perhaps an even easier fix, that solved the issue when I was running into it:
Regardless of whether you have already installed it by other means, run:
While this might tell you that the plugin is already installed, this will also sort out the pathing for you, which should fix the issue.
我发现确保您已完成以下工作
插入
compile“:shiro:1.2.1”
到BuildConfig.groovy
运行命令
grails编译
在项目中右键单击> Grails 工具 >刷新依赖关系
I found that making sure you have done the following worked
Inserted
compile ":shiro:1.2.1"
intoBuildConfig.groovy
Run the command
grails compile
right click in the project > grails tools > refresh dependencies