4

我正在使用从 github.com 下载的示例 Lift 框架。Scala 2.9.1 是其中的版本。我在 cmd 中使用 Container:start 命令来启动服务器,我可以在 localhost:8080 中看到该应用程序。但我已经在 Eclipse 中安装了 scala 2.10.0。如果我将项目与 Eclipse IDE 集成,则 localhost:8080 会显示一些错误。问题是什么?

我有build.sbt

name := "Lift 2.5 starter template"

version := "0.0.1"

organization := "net.liftweb"

scalaVersion := "2.9.1"

resolvers ++= Seq("snapshots"     at      "http://oss.sonatype.org/content/repositories/snapshots",
            "releases"        at "http://oss.sonatype.org/content/repositories/releases"
            )

seq(com.github.siasia.WebPlugin.webSettings :_*)

unmanagedResourceDirectories in Test <+= (baseDirectory) { _ / "src/main/webapp" }

scalacOptions ++= Seq("-deprecation", "-unchecked")

libraryDependencies ++= {
  val liftVersion = "2.5-RC2"
  Seq(
    "net.liftweb"       %% "lift-webkit"        % liftVersion        % "compile",
    "net.liftweb"       %% "lift-mapper"        % liftVersion        % "compile",
    "net.liftmodules"   %% "lift-jquery-module" % (liftVersion + "-2.2"),
    "org.eclipse.jetty" % "jetty-webapp"        % "8.1.7.v20120910"  % "container,test",
    "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container,test"  artifacts Artifact("javax.servlet", "jar", "jar"),
    "ch.qos.logback"    % "logback-classic"     % "1.0.6",
    "org.specs2"        %% "specs2"             % "1.12.1"           % "test",
    "com.h2database"    % "h2"                  % "1.3.167"
  )
}

我已经在 projects/plugins.sbt 中与 Eclipse 集成

 addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0")
4

1 回答 1

2

要更新 Eclipse,您需要更新 ScalaIDE 插件以使用 2.10。 http://download.scala-ide.org/sdk/e37/scala210/dev/site/

如果你的build.sbtorplugin.sbt包含一行说:

scalaVersion := "2.10.0"

SBT 将找到该行,对其进行解释,并自动下载 2.10 Scala 编译器和 2.10 Scala 库以用于类型安全存储库。这可以在类型安全解析器中找到,它通常作为全局解析器添加到 中~/.sbt/,就像这样resolvers += Classpaths.typesafeResolver

如果您将scalaVersion := "2.10.0"在构建定义中使用一行来编译项目(对于插件也是如此)并且您没有安装 Scala 2.10 或在您的路径中,那么 SBT 将自动从类型安全解析器下载它并将下载的文件放入 ~/.sbt/boot/scala-2.10.0/lib/,您将在其中找到以下文件:

jansi.jar, jline.jar, scala-compiler.jar, scala-library.jar, scala-reflect.jar

这是build.sbt最初使用 Scala 2.9.2 创建的 lift 2.5M3 应用程序的示例配置,升级到 2.10。

name := "secret"

version := "0.1-SNAPSHOT"

scalaVersion := "2.10.0"

seq(com.github.siasia.WebPlugin.webSettings :_*)

seq(jrebelSettings: _*)

jrebel.webLinks <++= webappResources in Compile

resolvers ++= Seq(
    "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
    "Sonatype releases" at "https://oss.sonatype.org/content/repositories/releases",
    "Scala 2.10 support for rogue" at "https://github.com/mattpap/rogue/"
)

libraryDependencies ++= {
    val liftVersion = "2.5-M4"
    Seq(
      "com.foursquare" %% "rogue-field" % "2.0.0-beta22",
      "com.foursquare" %% "rogue-core" % "2.0.0-beta22",
      "com.foursquare" %% "rogue-lift" % "2.0.0-beta22",
      "net.liftweb" %% "lift-webkit" % liftVersion % "compile",
      "net.liftweb"    %% "lift-mongodb-record" % "2.5-M4",
      "com.mongodb.casbah" % "casbah_2.9.0" % "2.2.0-SNAPSHOT",
      "org.specs2" %% "specs2" % "1.12.3" % "test"
     )
}

classpathTypes ~= (_ + "orbit")

libraryDependencies ++= Seq(
  "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container" artifacts (Artifact("javax.servlet", "jar", "jar")
  )
)

libraryDependencies ++= Seq(
  "org.eclipse.jetty" % "jetty-webapp" % "8.1.7.v20120910" % "container" artifacts (Artifact("jetty-webapp", "jar", "jar")
  )
) 

port in container.Configuration := 5555

EclipseKeys.withSource := true

这是plugins.sbt文件,应该在PROJECTROOT/project/plugins.sbt

libraryDependencies <+= sbtVersion(v => v match {
  case "0.11.0" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.0-0.2.8"
  case "0.11.1" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.1-0.2.10"
  case "0.11.2" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.2-0.2.11"
  case "0.11.3" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.3-0.2.11.1"
  case x if (x.startsWith("0.12")) =>
    "com.github.siasia" %% "xsbt-web-plugin" % "0.12.0-0.2.11.1"
})

resolvers += "Jawsy.fi M2 releases" at "http://oss.jawsy.fi/maven2/releases"

addSbtPlugin("fi.jawsy.sbtplugins" %% "sbt-jrebel-plugin" % "0.9.0")

这是全局插件文件,它应该在 ~/.sbt/plugins/plugins.sbt如果你把东西放在这里,它将被加载到你所有的 SBT 项目中,系统范围内。当然,这仅代表您的机器。

resolvers += Classpaths.typesafeResolver

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0")

resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.5.0")

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0")

resolvers += "Jawsy.fi M2 releases" at "http://oss.jawsy.fi/maven2/releases"

addSbtPlugin("fi.jawsy.sbtplugins" %% "sbt-jrebel-plugin" % "0.9.0")
于 2013-03-14T11:21:43.633 回答