如何使用jetty.port覆盖jetty.xml [英] How to override jetty.xml with jetty.port
问题描述
我正在使用maven-jetty-plugin并尝试使用-Djetty.port = 8090覆盖我的jetty.xml设置但它无效。只有当我从jetty.xml文件中删除连接器部分时,我才能将端口设置为8090。
I'm using maven-jetty-plugin and trying to override my jetty.xml setting with the -Djetty.port=8090 but it's not working. Only when I remove the connector part from the jetty.xml file I get the port to be 8090.
所以:
mvn jetty:run -Djetty.port=8090
连接器从端口8080开始
With the connector starts in port 8080
没有连接器从端口8090开始
Without the connector starts in port 8090
问题是我需要配置接受器,统计和其他东西。我尝试仅从连接器中删除端口,但它不起作用。
Problem is I need to configure acceptors, stats and other stuff. I tried removing only the port from the connector but it didn't work.
我正在使用:
JAVA 1.7_05
MAVEN 3.0.4
Jetty 8.1.4
Linux Ubuntu 12.04 64bits
这是我的pom.xml插件配置:
Here's my pom.xml plugin configuration:
<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:
Jetty.xml connector 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中使用SystemProperty而不是Property。没有工作
UPDATE 1: Also tried using SystemProperty instead of Property in the jetty.xml. Did not work
推荐答案
更新1:确实有效。不知道为什么,但我尝试使用主机也作为SystemProperty,它工作。然后我删除了主机并且也工作了。
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.
所以最终修复工作jetty.xml连接器conf:
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>
这篇关于如何使用jetty.port覆盖jetty.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!