简体   繁体   English

删除Play Framework项目中IntelliJ中的错误指示

[英]Remove error-indication in IntelliJ in Play Framework project

My method in my Application-class shows an error in IntelliJ that isn't an error. 我的Application-class中的方法在IntelliJ中显示错误,这不是错误。 The method works fine in my browser and as you know (if you're familiar with Play) compile-errors will show in your browser when you run the program. 该方法在我的浏览器中正常工作,如您所知(如果您熟悉Play),编译错误将在您运行程序时显示在浏览器中。 My method works just as planned, but the error-indication in the IDE won't go away. 我的方法按计划工作,但IDE中的错误指示不会消失。

If you use Eclipse (Scala IDE) you just run the activator eclipse command in the command-line and the IDE won't complain anymore - is there a similar fix for IntelliJ? 如果您使用Eclipse(Scala IDE),您只需在命令行中运行activator eclipse命令,IDE就不会再抱怨 - IntelliJ是否有类似的修复?

Edit: I use Play 2.4, so the activator idea command doesn't work either: Play Framework 2.4 and IntelliJ Idea 编辑:我使用Play 2.4,因此activator idea命令也不起作用: Play Framework 2.4和IntelliJ Idea

Edit 2: Not a duplicate of IntelliJ Ultimate can't find routes in Play 2.3 (Java) project tests because that one is about the IDE not finding routes, and mine is about wrong error-indication with different solutions to different problems. 编辑2:不是IntelliJ Ultimate的副本无法在Play 2.3(Java)项目测试中找到路由,因为那个是关于IDE没有找到路由,而我的是错误的错误指示与不同的问题的不同解决方案。 For the correct solution see the accepted answer. 有关正确的解决方案,请参阅接受的答案

IDEA 14.1.3 doesn't set the classpath correctly when importing a Play 2.4 application. 导入Play 2.4应用程序时,IDEA 14.1.3未正确设置类路径。 By default target folder is excluded from the classpath. 默认情况下, target文件夹从类路径中排除。 However the twirl templates and routes are compiled to the target folder and need to be available to the classpath. 但是,旋转模板和路径将编译到目标文件夹,并且需要可用于类路径。

To fix the issue 解决问题

  1. Make sure your classes and templates are compiled: Build > Make 确保编译您的类和模板: Build > Make
  2. Open File > Project Structure 打开File > Project Structure
  3. Go to Modules menu and select the root module 转到“ Modules菜单,然后选择root模块
  4. Go to the Sources tab 转到“ Sources选项卡
  5. Remove the target folder from the excludes by clicking on the X next to it in the right panel 通过单击右侧面板中旁边的X从排除中删除target文件夹
  6. Click Apply 单击“应用”

You can then see that target\\scala-2.11\\routes\\main and target\\scala-2.11\\twirl\\main are recognized as source folders properly. 然后,您可以看到target\\scala-2.11\\routes\\maintarget\\scala-2.11\\twirl\\main被正确识别为源文件夹。

Your error should then go away. 然后你的错误就会消失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM