Play 框架 - java.lang.RuntimeException:未检测到主类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24684799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 14:06:28  来源:igfitidea点击:

Play framework - java.lang.RuntimeException: No main class detected

javaplayframeworksecuresocial

提问by ad-inf

I am new to play framework and trying to run securesocial as in https://github.com/jaliss/securesocialUsing Play 2.3, Scala 2.10.0

我是玩框架的新手,并尝试在https://github.com/jaliss/securesocial 中使用 Play 2.3、Scala 2.10.0运行 securesocial

.sbt file is configured as

.sbt 文件配置为

name := "SecureSocial-parent"

version := Common.version

scalaVersion := Common.scalaVersion

lazy val core =  project.in( file("module-code") ).enablePlugins(PlayScala)

lazy val scalaDemo = project.in( file("samples/scala/demo") ).enablePlugins(PlayScala).dependsOn(core)

lazy val javaDemo = project.in( file("samples/java/demo") ).enablePlugins(PlayJava).dependsOn(core)

lazy val root = project.in( file(".") ).aggregate(core, scalaDemo, javaDemo) .settings(
     aggregate in update := false
   )

But getting below error

但低于错误

~\securesocial-master>activator run
[info] Loading project definition from ~\securesocial-master\project
[info] Set current project to SecureSocial-parent (in build file:~/securesocial-master/)
java.lang.RuntimeException: No main class detected.
        at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last securesocial-master/compile:run for the full output.
[error] (securesocial-master/compile:run) No main class detected.

The project compiled successfully with many warnings on deprecated API Any pointer will be useful on how to resolve the no main class error

项目编译成功,但在已弃用的 API 上有许多警告 任何指针都将有助于解决无主类错误

采纳答案by vektor

As far as I understand it, SecureSocial-parent is just the library - it can be compiled, but cannot be runper se. You can only run the demo projects. For example, if you start activatorin the securesocialdirectory, you can type

据我了解, SecureSocial-parent 只是一个库 - 它可以编译,但本身不能运行。您只能运行演示项目。例如,如果activatorsecuresocial目录中启动,则可以键入

project javaDemo

to switch to the Java demo project and then

切换到 Java 演示项目,然后

~run

to run it.

运行它。

回答by user2861691

Just had the same problem. I am using the scala version though. I am running the sample app directly from the samples/scala/demo folder (by typing activator in the terminal).

刚刚有同样的问题。不过,我正在使用 Scala 版本。我直接从 samples/scala/demo 文件夹运行示例应用程序(通过在终端中键入 activator)。

The key to get it up and running was to add the following line to scalaDemo.sbt

启动并运行它的关键是将以下行添加到 scalaDemo.sbt

lazy val root = (project in file(".")).enablePlugins(PlayScala)

which should probably be

这应该是

lazy val root = (project in file(".")).enablePlugins(PlayJava)

into the javaDemo.sbt file, since you are running the Java version.

进入 javaDemo.sbt 文件,因为您正在运行 Java 版本。

I can see when the app starts that I have problems loading some gifs in the public folder, so maybe it is a wrong approach.

我可以看到应用程序启动时我在公共文件夹中加载一些 gif 时遇到问题,所以这可能是一种错误的方法。