【问题标题】:jetty-maven-plugin setting buffers sizesjetty-maven-plugin 设置缓冲区大小
【发布时间】:2012-08-10 13:20:13
【问题描述】:

返回 jetty-maven-plugin 我无法设置缓冲区大小。

我的用例意味着文件上传(通常大小约为 700Ko)。 因为对于 jetty-maven-plugin 默认配置来说上传太大,所以我收到带有错误状态代码 413 的 Http 响应(请求太大)

我尝试使用插件配置:

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>${jetty-maven.version}</version>
    <configuration>
        <scanIntervalSeconds>3</scanIntervalSeconds>

        <connectors>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <port>8080</port>
                <maxIdleTime>60000</maxIdleTime>
                <requestHeaderSize>8192</requestHeaderSize>
                <requestBufferSize>2097152</requestBufferSize>
            </connector>
        </connectors>
    </configuration>
</plugin>

然后我尝试将 jetty-maven-plugin 与 jetty.xml 文件一起使用

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>${jetty-maven.version}</version>
    <configuration>
        <scanIntervalSeconds>3</scanIntervalSeconds>
        <jettyConfig>${basedir}/src/main/config/jetty/jetty.xml</jettyConfig>
    </configuration>
</plugin>

jetty.xml 如下:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"     "http://jetty.mortbay.org/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
 <Call name="addConnector">
  <Arg>
   <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
    <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
    <Set name="requestHeaderSize">8192</Set>
    <Set name="requestBufferSize">2097152</Set>
   </New>
  </Arg>
 </Call>
</Configure>

没有任何作用。 有人可以给我正确的配置吗?

【问题讨论】:

    标签: maven jetty maven-jetty-plugin


    【解决方案1】:

    按此更改您的 pom 并将这两个 xml 文件添加到您的项目中。希望对你有用。

            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.2.11.v20150529</version>
                <configuration>
                    <contextPath>/random-api</contextPath>
                    <scanIntervalSeconds>5</scanIntervalSeconds>
                    <jettyXml>jetty.xml,jetty-http.xml</jettyXml>
                </configuration>
            </plugin>
    

    ===============jetty.xml和jetty-http.xml================= https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty.xml

    https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-http.xml

    【讨论】:

      【解决方案2】:

      我不确定这是否解决了您的用例中的问题,但您可以尝试将以下内容添加到 maven-jetty-plugin 的 &lt;configuration&gt; 部分:

      <systemProperties>
          <systemProperty>
              <name>org.eclipse.jetty.server.Request.maxFormContentSize</name>
              <value>-1</value> <!-- or any other value -1 is for max -->
           </systemProperty>
      <systemProperties>
      

      jesse mcconnell 所述,该物业在 7/8 码头重命名为 org.eclipse.jetty.server.Request.maxFormContentSize

      对于我来说,6 号码头 org.mortbay.jetty.Request.maxFormContentSize 正在工作。

      【讨论】:

      • 感谢您的帮助。我试试
      【解决方案3】:

      暂停(午餐)后,我拿起了我应该测试的网络应用程序的代码。 其“内部”配置存在冗余限制(使用具有自身大小限制的上传代理)。

      事实上,为码头提出的两种配置都可以工作(现在 web-app 没有任何多余的限制)

      【讨论】:

      • 感谢您的帮助。如前所述,应用服务器设置受到应用设置限制的影响。换句话说,拒绝大量上传的是应用程序,而不是服务器。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-10
      • 1970-01-01
      • 1970-01-01
      • 2017-05-29
      • 1970-01-01
      相关资源
      最近更新 更多