How to override jetty.xml with jetty.port

霸气de小男生 提交于 2019-11-29 06:16:41

UPDATE 1: did work. Don't know why but I tried it with the host also as SystemProperty and it worked. Then I removed host and worked also.

So final fix working jetty.xml connector 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>

I had the same problem. Fix:

In the properties section of the pom, define jetty.port:

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

In the plugin configuration:

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

This enables to override the port on command line with

mvn -D jetty.port=9999 jetty:run

if you are using ./jetty.sh start command to start the server, it read configure from start.ini or start.d in base folder, please try to change port (jetty.port) in that and restart the server.

Just remove the SystemProperty markup inside "port", and put the new port value inside "port" markup:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!