简体   繁体   English

尽管存在错误,Java Play应用程序仍在运行-如何解决此错误?

[英]Java play application running despite of having errors- how to resolve this errors?

I just started with play using activator, I created new play app using 我刚开始使用激活器进行游戏,我使用创建了新的游戏应用程序

activator new firstApp play-java

Then I opened play console using activator and run the application, app was running fine. 然后我使用激活器打开播放控制台并运行该应用程序,该应用程序运行良好。 Then I opened the project in my intellij as SBT, the project opened and started showing errors. 然后,我在intellij中以SBT形式打开该项目,该项目打开并开始显示错误。

in routes file there were lines 在路由文件中有行

GET     /                        controllers.HomeController.index
GET     /count                   controllers.CountController.count
GET     /message                 controllers.AsyncController.message

This errors are because method index, count and message are not static. 该错误是因为方法索引,计数和消息不是静态的。 This is an obvious error since we cannot call to static method like this, why the code application is still running. 这是一个明显的错误,因为我们不能像这样调用静态方法,因此代码应用程序仍在运行。

another error I am getting is in code 我得到的另一个错误是代码

actorSystem.scheduler().scheduleOnce(
        Duration.create(time, timeUnit),
        () -> future.complete("Hi!"),
        exec
    );

It says this is an ambiguous method call. 它说这是一个模棱两可的方法调用。

My question is, if there are errors why application is running without 我的问题是,如果有错误,为什么应用程序不运行

I created run configuration as SBT task and tried to run the app an I got bunch of errors. 我将运行配置创建为SBT任务,并尝试运行该应用程序,但出现了很多错误。

These worked for me: 这些对我有用:

Open file root\\build.sbt and click 'Import Project' or 'Refresh Project'. 打开文件root \\ build.sbt,然后单击“导入项目”或“刷新项目”。 Open file project\\plugins.sbt and click 'Import Project' or 'Refresh Project'. 打开文件project \\ plugins.sbt,然后单击“导入项目”或“刷新项目”。

This will import all required libraries and after completing libraries will be visible under project view pane 'External Libraries' tree. 这将导入所有必需的库,并在完成库后在项目视图窗格的“外部库”树下可见。

Go to File > Settings, select 'Play2' under 'Languages & Frameworks'. 转到“文件”>“设置”,在“语言和框架”下选择“ Play2”。 Under right side Compiler tab check 'Use Play 2 compiler for this project' and Apply settings. 在右侧的“编译器”选项卡下,选中“为此项目使用Play 2编译器”并应用设置。

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

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