【发布时间】:2020-05-24 06:20:20
【问题描述】:
我创建了一个网络应用程序,当我尝试使用sbt run 运行时,它显示:
sbt run
[warn] No sbt.version set in project/build.properties, base directory: /home/developer/scala/user-svc/target/scala-2.13
[info] Loading global plugins from /home/developer/.sbt/1.0/plugins
[info] Set current project to scala-2-13 (in build file:/home/developer/scala/user-svc/target/scala-2.13/)
[error] java.lang.RuntimeException: No main class detected.
[error] at scala.sys.package$.error(package.scala:30)
[error] stack trace is suppressed; run last Compile / bgRun for the full output
[error] (Compile / bgRun) No main class detected.
[error] Total time: 0 s, completed May 23, 2020, 11:44:32 PM
build.sbt的内容是:
val Http4sVersion = "0.21.4"
val CirceVersion = "0.13.0"
val Specs2Version = "4.9.3"
val LogbackVersion = "1.2.3"
lazy val root = (project in file("."))
.settings(
organization := "io.example",
name := "user-svc",
version := "0.0.1-SNAPSHOT",
scalaVersion := "2.13.2",
libraryDependencies ++= Seq(
"org.http4s" %% "http4s-jetty" % Http4sVersion,
"org.http4s" %% "http4s-jetty-client" % Http4sVersion,
"org.http4s" %% "http4s-circe" % Http4sVersion,
"org.http4s" %% "http4s-dsl" % Http4sVersion,
"io.circe" %% "circe-generic" % CirceVersion,
"org.specs2" %% "specs2-core" % Specs2Version % "test",
"ch.qos.logback" % "logback-classic" % LogbackVersion
),
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3"),
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
)
scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-language:higherKinds",
"-language:postfixOps",
"-feature",
"-Xfatal-warnings",
)
文件夹结构应该是正确的:
我做错了什么?
【问题讨论】: