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

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...