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

4

我正在使用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/"

project/plugins.sbt

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

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

我该如何更改contextPath?有什么建议吗?提前感谢!


我在scalatra-user组得到了答案,请参考:http://groups.google.com/group/scalatra-user/browse_thread/thread/cc3883be7d01d61f - Septem
你可以回答自己的问题。为什么不将邮件列表中的答案作为解决方案的答案包含在此处,以便在同一位置记录解决方案呢? - Steffen
我认为你只需要一点声望就可以回答自己的问题了。点击此处了解更多信息。 - Bluu
要启用configurationXml,必须将customConfiguration参数设置为true,否则它不会应用。然而,由于类路径等问题,我无法使其正常工作,并且没有找到任何工作的configurationXml示例。它完全替换了xsbt-web-plugin完成的配置,因此必须从头开始配置所有内容:连接器、上下文处理程序、类路径等。 - kolen
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>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接