如何配置jetty来侦听多个端口(how to configure jetty to listen to multiple ports)

编程入门 行业动态 更新时间:2024-10-28 08:21:18
如何配置jetty来侦听多个端口(how to configure jetty to listen to multiple ports)

我只是想配置jetty来监听多个端口。 我不想要多个实例,也不需要多个webapps,只需一个jetty,一个webapp,但是可以监听2个或多个端口。

默认方式不支持多个条目:

<Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>

感谢您的帮助!

I just want to configure jetty to listen to more than one port. I don't want multiple instances nor multiple webapps, just one jetty, one webapp, but listening to 2 or more ports.

The default way does not support multiple entries:

<Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>

Thank you for your help!

最满意答案

在您的jetty.xml文件中,添加一个新的连接器:

<!-- original connector on port 8080 --> <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">2</Set> <Set name="statsOn">false</Set> <Set name="confidentialPort">8443</Set> <Set name="lowResourcesConnections">20000</Set> <Set name="lowResourcesMaxIdleTime">5000</Set> </New> </Arg> </Call> <!-- new connector on port 8081 --> <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="8081"/></Set> <Set name="maxIdleTime">300000</Set> <Set name="Acceptors">2</Set> <Set name="statsOn">false</Set> <Set name="lowResourcesConnections">20000</Set> <Set name="lowResourcesMaxIdleTime">5000</Set> </New> </Arg> </Call>

然后开始码头

java -jar start.jar etc\jetty.xml

应该做你想做的。

In your jetty.xml file, add a new connector:

<!-- original connector on port 8080 --> <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">2</Set> <Set name="statsOn">false</Set> <Set name="confidentialPort">8443</Set> <Set name="lowResourcesConnections">20000</Set> <Set name="lowResourcesMaxIdleTime">5000</Set> </New> </Arg> </Call> <!-- new connector on port 8081 --> <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="8081"/></Set> <Set name="maxIdleTime">300000</Set> <Set name="Acceptors">2</Set> <Set name="statsOn">false</Set> <Set name="lowResourcesConnections">20000</Set> <Set name="lowResourcesMaxIdleTime">5000</Set> </New> </Arg> </Call>

Then start jetty

java -jar start.jar etc\jetty.xml

Should do what you want.

更多推荐

jetty,port,default,multiple,webapp,电脑培训,计算机培训,IT培训"/> <meta name=

本文发布于:2023-07-08 19:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1079986.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   端口   jetty   configure   ports

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!