【问题标题】:how to set the contextPath of jetty on xsbt-web-plugin?如何在 xsbt-web-plugin 上设置码头的 contextPath?
【发布时间】:2013-07-02 10:39:41
【问题描述】:

我在 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"))

似乎配置xml不起作用,在sbt控制台中运行container:start后,contextPath得到了默认值“/”

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

【问题讨论】:

  • 我在scalatra-user组上得到了答案,请参考:groups.google.com/group/scalatra-user/browse_thread/thread/…
  • 您可以回答自己的问题。为什么不将邮件列表中的答案作为对您问题的答案来记录解决方案?
  • 我认为you can answer your own question now 名气不大。
  • 要启用configurationXmlcustomConfiguration参数应该设置为true,否则不应用。但是,由于类路径等问题,我无法让它工作,也没有找到任何工作样本configurationXml。它完全取代了 xsbt-web-plugin 完成的配置,因此必须从头开始配置所有内容:连接器、上下文处理程序、类路径。

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


【解决方案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>

【讨论】:

    猜你喜欢
    • 2014-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-17
    • 2020-08-08
    • 2014-06-13
    • 2018-06-29
    相关资源
    最近更新 更多