如何使用org.eclipse.jetty:jetty-maven-plugin设置服务器端口? [英] How to set server port with org.eclipse.jetty:jetty-maven-plugin?

查看:817
本文介绍了如何使用org.eclipse.jetty:jetty-maven-plugin设置服务器端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在通过jetty.xml文件设置端口,并且我一直在尝试从新文档中找出如何通过Maven插件的配置实际定义httpConnector的方法. Eclipse网站上的文档似乎有点含糊不清,我已经尝试了一段时间,因此最终使用了jetty.xml.我现在想找出执行此操作的正确方法.

I am currently setting the port via a jetty.xml file and I've been trying to figure out from the new documentation how to actually define an httpConnector through the Maven plugin's configuration. The docs on Eclipse's site seem a bit vague on it and I've been trying to figure this out for a while, thus ending up using a jetty.xml. I'd like to find out the proper way to do this now.

我当前正在使用org.eclipse.jetty:jetty-maven-plugin:9.2.1.v20140609.

推荐答案

The jetty-maven-plugin documentation states that you can either configure the httpConnector element in the pom.xml file to setup the ServerConnector preferences or use the jetty.http.port system property to change the port or use the Jetty descriptor i.e. the way you are doing it actually. And then you have several options:

  • 仅在运行时更改端口:

  • Change the port when just at runtime:

mvn jetty:run -Djetty.http.port=9999

  • pom.xml 文件中设置属性:

  • Set the property inside your pom.xml file:

    <properties>
      <jetty.http.port>9999</jetty.http.port>
    </properties>
    

    然后运行:

    mvn jetty:run
    

  • pom.xml 文件内的插件声明中设置端口:

  • Set the port in your plugin declaration inside the pom.xml file:

    <build>
      <plugins>
        <plugin>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-maven-plugin</artifactId>
          <version>9.2.1.v20140609</version>
          <configuration>
            <httpConnector>
              <!--host>localhost</host-->
              <port>9999</port>
            </httpConnector>
          </configuration>
        </plugin>
      </plugins>
    </build>
    

  • jetty-maven-plugin 的新版本中, jetty.http.port已过时,将无法使用. 如果上述说明无效,您可以尝试jetty.port.

    In new versions of jetty-maven-plugin, jetty.http.port is deprecated and won't work. You can try jetty.port if the instruction above doesn't work.

    这篇关于如何使用org.eclipse.jetty:jetty-maven-plugin设置服务器端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆