How to run multiple instances of jetty with maven

孤人 提交于 2019-11-28 01:52:21

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!