How to set server port with org.eclipse.jetty: jetty-maven-plugin?

I am currently setting the port through the jetty.xml file, and I was trying to figure out from the new documentation how to actually determine the httpConnector through the configuration of the Maven plugin. The documents on the Eclipse website seem a bit vague, and I tried to figure this out for a while, as a result of getting jetty.xml . I would like to find the right way to do it now.

I am currently using org.eclipse.jetty:jetty-maven-plugin:9.2.1.v20140609 .

+56
maven jetty
Sep 03 '14 at 12:14
source share
6 answers

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

  • Change the port only at runtime:

     mvn jetty:run -Djetty.http.port=9999 
  • Set the property inside your pom.xml file:

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

    Then just run:

     mvn jetty:run 
  • 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> 

EDIT

In newer versions of jetty.http.port jetty-maven-plugin , jetty.http.port deprecated and will not work. You can try jetty.port if the above instruction does not work.

+111
Sep 05 '14 at 11:04
source share

Run the following command: mvn jetty: run -Djetty.port = 9999

I think mvn jetty: run -Djetty.http.port = 9999 is deprecated. This did not work for me.

+18
Aug 29 '16 at 12:33
source share

You can configure the port through pom.xml :

 <build> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.2.1.v20140609</version> <configuration> <httpConnector> <port>9999</port> </httpConnector> </configuration> </plugin> </plugins> </build> 
+14
Sep 03 '14 at 12:38 on
source share

This works for me, confirmed as I am currently debugging a server in my chrome on port 8088.

  mvn jetty:run -Dhttp.port=8088 
+2
Oct 18 '17 at 15:24
source share

By default, Jetty runs on port 8080, if an application, such as an Oracle database, uses this port on your system, the Jetty server does not start and throws some BIND exception. to overcome this, if your project is a maven project, then use the code below in the pom.xml file, then it works fine (here I use port 8888, which is free on my system)

 <!-- The Jetty plugin allows us to easily test the development build by running jetty:run on the command line. --> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>${jetty.plugin.version}</version> <configuration> <scanIntervalSeconds>2</scanIntervalSeconds> <httpConnector> <host>localhost</host> <port>8888</port> </httpConnector> </configuration> </plugin> 
0
Mar 22 '18 at 9:39
source share

How to change port of gretty plugin in Gradle?

0
Feb 02 '19 at 7:33
source share



All Articles