时间:2017-09-02 00:09:23

标签: scala sbt jetty scalatra scalatra-sbt

我创建了Scalatara应用程序来构建Web服务。它使用Jetty服务器,当我创建项目本身时,它包含在 build.sbt 文件中。

但是当我尝试使用命令 - jetty:start 启动jetty服务器时,它会向我显示错误消息&#34;不是有效密钥:jetty&#34; < / strong>即可。然后,当我检查构建文件时,它会在下面的依赖项中显示一条警告消息,作为&#34; sbt&#34; 中的未知工件。

  

&#34; org.eclipse.jetty&#34; %&#34; jetty-webapp&#34; %&#34; 9.4.6.v20170531&#34; %&#34;容器&#34;

我使用了MVN Repository中的最新依赖项,但仍显示相同的错误。我还有什么需要做的吗?

2 个答案:

答案 0 :(得分:0)

您是如何创建项目的?有没有办法告诉我,所以我可以重现它。弄清楚会更容易。无论如何,您可以尝试首先将解析器添加到build.sbt:

resolvers += "Jetty" at "https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-webapp"

答案 1 :(得分:0)

请比较下面显示的build.sbt文件的代码,如果有任何遗漏,请在build.st文件中更新。

import org.scalatra.sbt._
import org.scalatra.sbt.PluginKeys._
import ScalateKeys._

val ScalatraVersion = "2.5.1"

ScalatraPlugin.scalatraSettings

scalateSettings

organization := "com.github.karthikeyana"

name := "My Scalatra Web App"

version := "0.1.0-SNAPSHOT"

scalaVersion := "2.12.3"

resolvers += Classpaths.typesafeReleases

libraryDependencies ++= Seq(
  "org.scalatra" %% "scalatra" % ScalatraVersion,
  "org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
  "org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
  "ch.qos.logback" % "logback-classic" % "1.1.5" % "runtime",
  "org.eclipse.jetty" % "jetty-webapp" % "9.2.15.v20160210" % "container",
  "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
  "org.mongodb" %% "casbah" % "3.1.1"
)

scalateTemplateConfig in Compile := {
  val base = (sourceDirectory in Compile).value
  Seq(
    TemplateConfig(
      base / "webapp" / "WEB-INF" / "templates",
      Seq.empty,  /* default imports should be added here */
      Seq(
        Binding("context", "_root_.org.scalatra.scalate.ScalatraRenderContext", importMembers = true, isImplicit = true)
      ),  /* add extra bindings here */
      Some("templates")
    )
  )
}

enablePlugins(JettyPlugin)