Intellij IDEA 无法使用 Play 框架解析符号 [英] Intellij IDEA can not resolve symbol with Play framework

查看:27
本文介绍了Intellij IDEA 无法使用 Play 框架解析符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Play 2.2.1 中使用 IDEA 13,并在 play 上做示例网站.

I am using IDEA 13 with Play 2.2.1 and was doing the examples on the play site.

public static Result index() {
   return redirect(routes.Application.tasks());
}

IDEA 说无法解析方法重定向(?)"并用红色下划线标出routes.Application.tasks()

IDEA says "cannot resolve method redirect(?)" and red underlines routes.Application.tasks()

我已经从播放控制台完成了编译"和想法".

I have done "compile" and then "idea" from the play console.

推荐答案

我在测试控制器时遇到了类似的问题.我通过 "File" > 解决了它打开项目" 并选择 Play 框架项目的基础文件夹(删除之前文件夹中的所有想法设置文件,以便使用 SBT 设置重新导入).

I had a similar problem when testing my controller. I solved it by "File" > "Open Project" and choose the base folder of the Play framework project (delete all idea settings file from the folder before so that it will reimport using the SBT settings).

对 IDEA 的 SBT 支持的最后一个版本完成了 90% 的工作.然后F4进入模块设置对话框.如下图所示设置您的项目依赖项(亮红色文件夹已由 IDEA 设置,在我的项目中尚不存在,所以不要担心它们是否存在于您的项目中).在想法将使用和索引的代码中包含托管类和生成的代码是一个问题.

The last version of the SBT support for IDEA did 90% of the work. Then F4 to enter module settings dialog. Set up your project dependencies like in the picture below (the bright red folder have been set by IDEA and do not exist yet in my project so do not worry if they do in yours). It is a matter of including managed classes and generated code in the code that idea will use and index.

现在我可以在 IDEA 中使用这样的代码并且调试它没有问题.

now I can use code like this from within IDEA and debug it no problem.

Result result = Helpers.callAction(controllers.routes.ref.CrudController.createEntity(CrudEntities.contact.name()),
        new FakeRequest().withJsonBody(paramJson)
);

你的做法也应该有效.

这篇关于Intellij IDEA 无法使用 Play 框架解析符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆