IntelliJ IDEA报告在Controller中使用路由时突出显示错误 [英] IntelliJ IDEA Report Highlighting error when using routes in Controller

查看:748
本文介绍了IntelliJ IDEA报告在Controller中使用路由时突出显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Scala Play项目。我正在使用Play 2.2.1。我下载了Scala,Play 2支持和SBT插件。一切都还可以,但是当我在控制器中调用路径时出现以下错误(查看截图):

I have a Scala Play project. I'm using Play 2.2.1. I downloaded Scala, Play 2 supported and SBT plugins. Everything is OK, but When I call route on Action in the Controller appear following error(Look screenshots):

我正在使用IntelliJ IDEA 12.1.6 Ultimate版本。 Scala版本2.10.2

I'm using IntelliJ IDEA 12.1.6 Ultimate version. Scala version 2.10.2

有谁知道如何解决这个问题?

Anybody know how to fix this problem?

提前致谢!


编辑

当我通过Play控制台中的play idea命令生成我的项目到Intellij IDEA时,我在IDEA项目结构中打开项目是这样的:

When I generate my project to Intellij IDEA via "play idea" command in play console, and I opened project in IDEA project structure was such:

然后我看到回答@millhouse并讨论这个githup( [Play 2.2]play idea创建了不工作的源映射目标)我从来源文件夹中删除了以下文件夹:

Then I saw answer @millhouse and discussing on this githup([Play 2.2] "play idea" creates not working source mapping in target) and I removed following folders from Sources Folders:



  • target\scala-2.10\src_managed\main\controllers

  • target\scala-2.10\src_managed\main\views

和报告突出显示错误消失了,但现在又出现了另一个错误:

我的路线:

我已经更改了Sources Folders,如下所示:

And I've changed "Sources Folders" as shown below:

但它对我没有帮助。并且仍然是未指定的值参数错误。

推荐答案

millhouse的回答帮助我找到了正确的答案。播放2.2(可能是早期版本,尚未检查)输出路径文件的scala版本到 project_dir / target / scala-2.10 / src_managed / main 所以对于IntelliJ来说获得突出显示权限,确保将 src_managed / main 添加为源文件夹。 javascript的反向路由由于某种原因包含在 project_dir / target / scala-2.10 / classes_managed 中,所以你也必须添加它。 (在你的截图中,它看起来像 classes_managed 被设置为排除,所以你需要通过按右侧的x按钮来取消它。)

millhouse's answer helped me find the right answer. Play 2.2 (and perhaps earlier versions, haven't checked) output a scala version of the routes file to project_dir/target/scala-2.10/src_managed/main So for IntelliJ to get the highlighting right you need to make sure that src_managed/main is added as a source folder. The reverse routes for javascript are for some reason included in project_dir/target/scala-2.10/classes_managed so you'll have to add that as well. (In your screenshot it looks like classes_managed is set to excluded so you'll want to un-exclude it by pressing the x button on the right hand side.)

这是我的项目结构的屏幕截图:

Here's a screen shot of my project structure:

更新

在Play 2.3(或者可能是IntelliJ的最新版本)中,添加classes_managed不再能解决问题。而不是将classes_managed添加到项目的源中,而是将其添加到它的依赖项中。通过这样做,IntelliJ应该能够获取已编译的routes.class。

In Play 2.3 (or perhaps recent versions of IntelliJ) adding the classes_managed no longer fixes the problem. Instead of adding classes_managed to the project's sources add it to it's dependencies. By doing that IntelliJ should be able to pick up the compiled routes.class.

这篇关于IntelliJ IDEA报告在Controller中使用路由时突出显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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