Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

java - How to run multiple instances of jetty with maven

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...