如何更改码头服务器的默认http端口

how to change default http port of jetty server

我无法更改 Jetty 服务器的默认 http 端口,我尝试了以下方法:
版本:jetty-distribution-9.4.19.v20190610
path/to/jetty/etc/jetty.xml 并在 Configuration 标签下添加 属性 如下:

<Set name="port">7070</Set>

使用上述配置,当我启动服务器时出现以下错误:

➜  bin ./jetty.sh start
Starting Jetty: 2019-08-06 14:05:08.458:INFO::main: Logging initialized @559ms to org.eclipse.jetty.util.log.StdErrLog
2019-08-06 14:05:08.578:WARN:oejx.XmlConfiguration:main: Config error at <Set name="port">7070</Set> java.lang.NoSuchMethodException: class org.eclipse.jetty.server.Server.setPort(class java.lang.String) in file:///Users/rprasad/sw/jetty-distribution-9.4.19.v20190610/etc/jetty.xml
2019-08-06 14:05:08.578:WARN:oejx.XmlConfiguration:main:
java.security.PrivilegedActionException: java.lang.NoSuchMethodException: class org.eclipse.jetty.server.Server.setPort(class java.lang.String)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1746)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.jetty.start.Main.invokeMain(Main.java:220)
    at org.eclipse.jetty.start.Main.start(Main.java:490)
    at org.eclipse.jetty.start.Main.main(Main.java:77)

然后我尝试在httpConfig下添加类似的配置,但还是不行。

<Set name="port"><Property name="jetty.http.port" deprecated="jetty.port" default="7070" /></Set>

以上配置出现以下错误:

➜  bin ./jetty.sh start
Starting Jetty: 2019-08-06 18:36:05.035:INFO::main: Logging initialized @535ms to org.eclipse.jetty.util.log.StdErrLog
2019-08-06 18:36:05.193:WARN:oejx.XmlConfiguration:main: Config error at <Set name="port"><Property name="jetty.http.port" deprecated="jetty.port" default="7070"/></Set> java.lang.NoSuchMethodException: class org.eclipse.jetty.server.HttpConfiguration.setPort(class java.lang.String) in file:///Users/kumar/sw/jetty-distribution-9.4.19.v20190610/etc/jetty.xml
2019-08-06 18:36:05.193:WARN:oejx.XmlConfiguration:main: Config error at <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration"><Set name="port"><Property name="jetty.http.port" deprecated="jetty.port" default="7070"/></Set><Set name="secureScheme"><Property name="jetty.httpConfig.secureScheme" default="https"/></Set><Set name="securePort"><Property name="jetty.httpConfig.securePort" deprecated="jetty.secure.port" default="8443"/></Set><Set name="outputBufferSize"><Property name="jetty.httpConfig.outputBufferSize" deprecated="jetty.output.buffer.size" default="32768"/></Set><Set name="outputAggregationSize"><Property name="jetty.httpConfig.outputAggregationSize" deprecated="jetty.output.aggregation.size" default="8192"/></Set><Set name="requestHeaderSize"><Property name="jetty.httpConfig.requestHeaderSize" deprecated="jetty.request.header.size" default="8192"/></Set><Set name="responseHeaderSize"><Property name="jetty.httpConfig.responseHeaderSize" deprecated="jetty.response.header.size" default="8192"/></Set><Set name="sendServerVersion"><Property name="jetty.httpConfig.sendServerVersion" deprecated="jetty.send.server.version" default="true"/></Set><Set name="sendDateHeader"><Property name="jetty.httpConfig.sendDateHeader" deprecated="jetty.send.date.header" default="false"/></Set><Set name="headerCacheSize"><Property name="jetty.httpConfig.headerCacheSize" default="4096"/></Set><Set name="delayDispatchUntilContent"><Property name="jetty.httpConfig.delayDispatchUntilContent" deprecated="jetty.delayDispatchUntilContent" default="true"/></Set><Set name="maxErrorDispatches"><Property name="jetty.httpConfig.maxErrorDispatches" default="10"/></Set><Set name="blockingTimeout"><Property deprecated="jetty.httpConfig.blockingTimeout" name="jetty.httpConfig.blockingTimeout.DEPRECATED" default="-1"/></Set><Set name="persistentConnectionsEnabled"><Property name="jetty.httpConfig.persistentConnectionsEnabled" default="true"/></Set><Set name="requestCookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.requestCookieCompliance" deprecated="jetty.httpConfig.cookieCompliance" default="RFC6265"/></Arg></Call></Set><Set name="responseCookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.responseCookieCompliance" default="RFC6265"/></Arg></Call></Set><Set name="multiPartFormDataCompliance"><Call class="org.eclipse.jetty.server.MultiPartFormDataCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.multiPartFormDataCompliance" default="RFC7578"/></Arg></Call></Set></New> java.lang.NoSuchMethodException: class org.eclipse.jetty.server.HttpConfiguration.setPort(class java.lang.String) in file:///Users/kumar/sw/jetty-distribution-9.4.19.v20190610/etc/jetty.xml
2019-08-06 18:36:05.194:WARN:oejx.XmlConfiguration:main:
java.security.PrivilegedActionException: java.lang.NoSuchMethodException: class org.eclipse.jetty.server.HttpConfiguration.setPort(class java.lang.String)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1746)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.jetty.start.Main.invokeMain(Main.java:220)
    at org.eclipse.jetty.start.Main.start(Main.java:490)
    at org.eclipse.jetty.start.Main.main(Main.java:77)

所以谁能帮我更改 Jetty 服务器的默认 http 吗?

尝试更改 start.ini 文件中的配置。 将 jetty.http.port=8080 更改为 jetty.http.port=7070