4

我在 sbt 0.11.1 和 xsbt-web-plugin 0.2.10

这里是 build.sbt 和 plugins.sbt

构建.sbt

organization := "org"

name := "demo"

version := "0.1.0-SNAPSHOT"

scalaVersion := "2.9.1"

seq(webSettings :_*)

configurationXml := 
                    <configuration>
                        <webApp>
                          <contextPath>/foo</contextPath>
                        </webApp>
                    </configuration>

libraryDependencies ++= Seq(
  "org.eclipse.jetty" % "jetty-webapp" % "7.4.5.v20110725" % "container",
  "javax.servlet" % "servlet-api" % "2.5" % "provided"
)

resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"

项目/plugins.sbt

libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.10"))

看来configurationXml不起作用,在sbt控制台中运行container:start后,contextPath获取默认值“/”

如何更改 contextPath?有小费吗?提前致谢!

4

1 回答 1

1

这是来自 scalatra-user 组的解决方案

将 jetty-plus 添加到依赖项:

"org.eclipse.jetty" % "jetty-plus" % "7.4.5.v20110725" % "container"

将此添加到 build.sbt:

env in Compile := Some(file(".") / "jetty-env.xml" asFile)

在与 build.sbt 相同的目录中,创建 jetty-env.xml:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/foo</Set>
</Configure>
于 2013-07-02T02:39:41.620 回答