如何在xsbt-web-plugin上设置jetty的contextPath?

时间:2011-12-10 01:00:06

标签: jetty sbt maven-jetty-plugin xsbt-web-plugin

我正在使用sbt 0.11.1和xsbt-web-plugin 0.2.10

这里是build.sbt和plugins.sbt

build.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控制台中启动,contextPath获取默认值“/”

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

1 个答案:

答案 0 :(得分: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>