0

回到 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>

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

4

3 回答 3

1

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

<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.

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

于 2012-08-14T09:16:22.793 回答
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/等/码头-http.xml

于 2017-01-12T13:48:47.587 回答
0

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

事实上,为码头提出的两种配置正在工作(现在网络应用程序没有任何多余的限制)

于 2012-08-14T13:01:06.267 回答