How to run multiple marina instances with maven

So, I want to configure the maven plugin jetty to run several - in my case, two berth server instances on different ports and with different applications.

So I want to have something like:

localhost:8080/webapp1 localhost:8081/webapp2 

And I want to do this with one command: mvn jetty: run which of course means that I have to configure it in pom.xml

I already have two different configuration files: jettyA.xml and jettyB.xml, which have different connectors. The only problem is that I cannot figure out how to do this with one pom.xml

I tried with two profiles, but somehow did not work. Only the pier in the last mentioned profile was launched.

+8
java maven jetty instances
source share
3 answers

Replace the port number in pom.xml of the property variable as follows:

 <port>${jetty.port}</port> 

Then run maven using the following command:

 mvn jetty:run -Djetty.port=8081 

To determine the default port number, add this default property to your pom file:

 <properties> <jetty.port>8080</jetty.port> </properties> 

If you need a more advanced method of determining the port number, you need to embed the marina in your main class.

+8
source share

This is how I sorted the above problem

1.) Go to RunRun Configurations or Debug Configurations in eclipse or STS (I used STS)

2.), then a dialog box will appear in the left menu. Double click on Maven Build

3.) at the top of the right side in the Name section Text Phase Enter the Anyname you want Example: - Jetty_Server

4.) below, select Workspace overview , then select the project that you want to clear intall and start with the berth server (I think you have already added the prefix plug-in to your pom file)

5.) below in the Target text box, enter the lines below (you can use 8020 or 8065 or any port)

 clean install -Djetty.port=8020 jetty:run 

6.), then configure the maven runtime (choose where your maven folder is installed)

7.), then apply -> Run / Debug

+2
source share

OK, I decided it like this ...

I have one POM.XML file with two different profiles. Then I wrote a SH script .. in which I run both profiles as follows:

 mvn jetty:run-war -Pprofile1 & mvn jetty:run-war -Pprofile2 

In each profile, I have my own configuration file (jettyA.xml, jettyB.xml), in which there are two servers defined on different ports - with different applications.

Now all I have to do is run one SH script and that is it.

+1
source share

All Articles