Pergunta

Estou usando o maven-jetty-plugin e tentando substituir minha configuração jetty.xml por -Djetty.port=8090 mas não está funcionando.Somente quando removo a parte do conector do arquivo jetty.xml a porta é 8090.

Então:

 mvn jetty:run -Djetty.port=8090

Com o conector começa na porta 8080

Sem o conector inicia na porta 8090

O problema é que preciso configurar aceitadores, estatísticas e outras coisas.Tentei remover apenas a porta do conector, mas não funcionou.

Estou a usar:

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

Aqui está a configuração do meu plugin 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>

Configuração do conector Jetty.xml:

<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>

Desde já, obrigado!

ATUALIZAÇÃO 1:Também tentei usar SystemProperty em vez de Property no jetty.xml.Não funcionou

Foi útil?

Solução

ATUALIZAÇÃO 1:funcionou.Não sei por que, mas tentei com o host também como SystemProperty e funcionou.Então removi o host e trabalhei também.

Então, correção final funcionando no conector 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>

Outras dicas

Eu tive o mesmo problema.Consertar:

Na seção de propriedades do pom, defina jetty.port:

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

Na configuração do plugin:

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

Isso permite substituir a porta na linha de comando por

mvn -D jetty.port=9999 jetty:run

se você estiver usando o comando ./jetty.sh start para iniciar o servidor, leia configure de start.ini ou start.d na pasta base, tente alterar a porta (jetty.port) nela e reinicie o servidor.

Basta remover a marcação SystemProperty dentro de "port" e colocar o novo valor da porta dentro da marcação "port":

enter image description here

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top