So, what I want to do is configure maven plugin jetty to run multiple - in my case two - instances of jetty server on different ports and with different apps.
So, I want to have something like:
localhost:8080/webapp1
localhost:8081/webapp2
And I want to do this with one single command: mvn jetty:run which of course means that I have to configure it in pom.xml
I already have two different jetty config files: jettyA.xml and jettyB.xml in which there are different connectors defined. The problem is just i can't figure it out how to do this with one pom.xml
I tried with two profiles but is somehow did not work. Just jetty in the last profile mentioned was started.
Replace the port number in pom.xml by a property variable like this:
<port>${jetty.port}</port>
Then run maven using the following command:
mvn jetty:run -Djetty.port=8081
To define a default port numer, add this default property to your pom file:
<properties>
<jetty.port>8080</jetty.port>
</properties>
If you need any more advanced method for determining the port number, you will need to embed jetty in your main class.
This is the way that I sorted the above issue
1.)Go to your Run -> Run Configurations or Debug Configurations in eclipse or STS (I used STS)
2.)then Dialog box will be appear & in left side menu Double Click on the Maven Build
3.)in top of the Right Side under Name Text phase Enter Anyname which you want Ex:- Jetty_Server
4.)below select Browse Workspace then select your project which you want to clean intall & run with jetty server (i think you already added jetty plugin in your pom file)
5.) below in Goal text box enter below line (you can use 8020 or 8065 or any port)
clean install -Djetty.port=8020 jetty:run
6.)then configure the maven runtime (select where is installed your maven folder)
7.)then apply -> Run/Debug
OK, i solved this like this...
I have one POM.XML file with two different profiles. Then i wrote a SH script.. in which I run both profiles like this:
mvn jetty:run-war -Pprofile1 &
mvn jetty:run-war -Pprofile2
In each profile I have it's own config file (jettyA.xml, jettyB.xml) in wich there are two servers defined on different ports - with different apps.
Now All i have to do is run one SH script and that is it.
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