xml - jetty 配置:dtd问题

标签 xml gradle jetty embedded-jetty

我正在使用jetty.xml嵌入在gradle项目中的jetty进行服务器配置。 jetty 有一个XML配置,以使用jettyRunWar(渐变插件)。

这是build.gradle中的jettyRunWar:

jettyRunWar{
    contextPath = "/"
    httpPort = 8080
    jettyConfig = file("./jetty.xml")
    reload = "automatic"
    scanIntervalSeconds = 10
    webApp = file("./build/libs/relevanteme.war")
}

这就是jetty.xml(配置)。
<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">

    <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>

    <New id="webApp" class="org.eclipse.jetty.webapp.WebAppContext">
            <Set name="contextPath">/</Set>
            <Set name="war"><SystemProperty name="jetty.home" default="."/>./build/libs/relevanteme.war</Set>

            <Call name="addServlet">
            <Arg>vjsantojaca.relevante.background.servlets.IdentifyServlet</Arg>
            </Call>
    </New>

    <New id="Relevante" class="org.eclipse.jetty.plus.jndi.Resource">
        <Arg>jdbc/Relevante</Arg>
        <Arg>
            <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
               <Set name="Url">jdbc:mysql://localhost:3306/mail_classmachine</Set>
               <Set name="User">classmach</Set>
               <Set name="Password">lTk54ifRd</Set>
            </New>
         </Arg>
    </New>

    <Set name="handler">
        <New class="org.eclipse.jetty.server.handler.HandlerCollection">
            <Set name="handlers">
                <Array type="org.eclipse.jetty.server.Handler">
                    <Item>
                        <Ref refid="webApp" />
                    </Item>
                    <Item>
                        <New class="org.eclipse.jetty.server.handler.DefaultHandler" />
                    </Item>
                </Array>
            </Set>
        </New>
    </Set>

</Configure>

当我在gradle中运行命令jettyRunWar并gradle下载jetty xml配置的dtd时,它为我提供了以下信息...
[org.mortbay.log] parsing: sid=file:/home/vjsantojaca/Developer/Relevante/relevanteme-web-2.0/jetty.xml,pid=null
[org.mortbay.log] resolveEntity(-//Jetty//Configure//EN, http://www.eclipse.org/jetty/configure_9_0.dtd)
[org.mortbay.log] Can't exact match entity in redirect map, trying configure_9_0.dtd
[sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@5df6163a5 pairs: {GET /jetty/configure_9_0.dtd HTTP/1.1: null}{User-Agent: Java/1.8.0_31}{Host: www.eclipse.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
[sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@2d313c8c14 pairs: {null: HTTP/1.1 200 OK}{Date: Tue, 14 Apr 2015 15:49:05 GMT}{Server: Apache}{Last-Modified: Tue, 11 Mar 2014 16:28:22 GMT}{ETag: "4e2795-239e-4f45735653580"}{Accept-Ranges: bytes}{Content-Length: 9118}{Vary: Accept-Encoding}{Access-Control-Allow-Origin: http://eclipse.org ; https://eclipse.org ; http://www.eclipse.org ; https://www.eclipse.org}{Access-Control-Allow-Methods: GET}{X-NodeID: (null)}{Keep-Alive: timeout=3, max=200}{Connection: Keep-Alive}{Content-Type: text/x-dtd}

为什么会这样呢?

谢谢!!

最佳答案

org.mortbay.log的引用意味着您正在使用Jetty-7之前的古老版本的Jetty(可能是Jetty 6)。

那就是你沮丧的原因。

您的jettyRunWar没有使用Jetty 9,而是使用了Jetty 6(?)

关于xml - jetty 配置:dtd问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29632414/

相关文章:

jenkins - 如何在 Jenkins 节点上安装gradle?

xml - 在 Golang 中解码时如何获取 XML 标签的字符数据和属性值

java - ServletContext 资源中的 XML 文档无效

java - 如何使用Android获取xml中的根元素?

android multidex 支持 firebase messaging api

gradle - 无法从 android studio 同步 gradle,但可以从控制台同步

java - New Relic Heroku Java 安装失败

java - mvn jetty :run looking for a file that doesn't exist

google-app-engine - 如何获取 Google App Engine 上的实际 URI?

c# - 根据 XSD 验证 XML 并忽略子元素的顺序