11

maven-jetty-pluginを使用していて、jetty.xml設定を-Djetty.port = 8090でオーバーライドしようとしていますが、機能していません。jetty.xmlファイルからコネクタ部分を削除した場合にのみ、ポートは8090になります。

それで:

 mvn jetty:run -Djetty.port=8090

コネクタはポート8080から始まります

コネクタなしでポート8090から開始

問題は、アクセプター、統計、その他のものを構成する必要があることです。コネクタからポートだけを外してみましたが、うまくいきませんでした。

私が使用しているもの:

JAVA 1.7_05
MAVEN 3.0.4
Jetty 8.1.4
Linux Ubuntu 12.04 64bits

これが私のpom.xmlプラグイン構成です:

<plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>8.1.4.v20120524</version>
            <configuration>
                <stopKey>foo</stopKey>
                <stopPort>9990</stopPort>
                <jettyXml>src/main/webapp/WEB-INF/jetty.xml</jettyXml>
            </configuration>
            <executions>
                <execution>
                    <id>start-jetty</id>
                    <!-- <phase>pre-integration-test</phase> -->
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <scanIntervalSeconds>0</scanIntervalSeconds>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-jetty</id>
                    <!-- <phase>post-integration-test</phase> -->
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
</plugin>

Jetty.xmlコネクタconf:

<Call name="addConnector">
  <Arg>
      <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
        <Set name="host"><Property name="jetty.host" /></Set>
        <Set name="port"><Property name="jetty.port" default="8080"/></Set>
        <Set name="maxIdleTime">300000</Set>
        <Set name="Acceptors">4</Set>
        <Set name="statsOn">false</Set>
        <Set name="confidentialPort">8443</Set>
    <Set name="lowResourcesConnections">20000</Set>
    <Set name="lowResourcesMaxIdleTime">5000</Set>
      </New>
  </Arg>
</Call>

前もって感謝します!

更新1:jetty.xmlでPropertyの代わりにSystemPropertyを使用してみました。動作しませんでした

4

4 に答える 4

7

更新1:動作しました。理由はわかりませんが、SystemPropertyとしてもホストで試してみたところ、うまくいきました。それから私はホストを削除し、また働きました。

したがって、最終的にはjetty.xmlコネクタconfの動作を修正します。

<Call name="addConnector">
  <Arg>
      <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
        <Set name="host"><SystemProperty name="jetty.host" /></Set>
        <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
        <Set name="maxIdleTime">300000</Set>
        <Set name="Acceptors">4</Set>
        <Set name="statsOn">false</Set>
        <Set name="confidentialPort">8443</Set>
    <Set name="lowResourcesConnections">20000</Set>
    <Set name="lowResourcesMaxIdleTime">5000</Set>
      </New>
  </Arg>
</Call>
于 2012-07-25T17:05:35.280 に答える
6

私も同じ問題を抱えていました。修理:

pomのプロパティセクションで、jetty.portを定義します。

<properties>
    <jetty.port>8888</jetty.port>
            ....
</properties>

プラグイン構成の場合:

<connectors>
    <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
        <maxIdleTime>3600000</maxIdleTime>
        <port>${jetty.port}</port>
    </connector>

これにより、コマンドラインのポートを次のようにオーバーライドできます。

mvn -D jetty.port=9999 jetty:run
于 2013-02-01T14:49:14.250 に答える
0

./jetty.sh startコマンドを使用してサーバーを起動している場合は、ベースフォルダーのstart.iniまたはstart.dからconfigureを読み取ります。その中のポート(jetty.port)を変更して、サーバーを再起動してください。

于 2014-03-26T09:12:26.227 に答える
0

「port」内のSystemPropertyマークアップを削除し、「port」マークアップ内に新しいポート値を配置するだけです。

ここに画像の説明を入力してください

于 2015-02-28T10:27:28.307 に答える