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.
I'm currently using org.eclipse.jetty:jetty-maven-plugin:9.2.1.v20140609
.
To modify the Jetty server port, open the Jetty v7. 0 Server at localhost, The Ports section is on the Overview tab (right panel). Either double click the port, or use the content menu. In the Port Number field, replace the current port number, 8080, with the new port number, in this example, 8081.
1.1 The 'groupId' is org. eclipse. jetty , by default, it runs on port 8080, in root context '/'.
The jetty-maven-plugin
documentation (for jetty 11 at the time of this answer - update) 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.
Then you have several options:
Change the port when just running your application through the mvn command:
mvn jetty:run -Djetty.http.port=9999
Set the property inside your project pom.xml descriptor file:
<properties> <jetty.http.port>9999</jetty.http.port> </properties>
Then just run your application through the Jetty plugin and the port will be picked up automatically:
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>
In new versions of jetty-maven-plugin
, jetty.http.port
is the default port property and jetty.port
won't work as in previous plugin versions.
Run following command: mvn jetty:run -Djetty.port=9999
I guess mvn jetty:run -Djetty.http.port=9999 is deprecated. It didn't work for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With