如何使用maven运行多个jetty实例 [英] How to run multiple instances of jetty with maven

查看:112
本文介绍了如何使用maven运行多个jetty实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我想要做的是配置maven插件jetty来运行多个 - 在我的情况下是两个 - 不同端口和不同应用程序上的jetty服务器实例。

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

我想用一个命令执行此操作:mvn jetty:run
当然这意味着我必须在pom.xml中配置它

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

我已经有两个不同的jetty配置文件:jettyA.xml和jettyB.xml,其中定义了不同的连接器。
问题是我无法弄明白如何使用一个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

我试过两个配置文件但是不知何故不起作用。
刚开始提到上一个配置文件中的jetty。

I tried with two profiles but is somehow did not work. Just jetty in the last profile mentioned was started.

推荐答案

用属性替换pom.xml中的端口号变量如下:

Replace the port number in pom.xml by a property variable like this:

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

然后使用以下命令运行maven:

Then run maven using the following command:

mvn jetty:run -Djetty.port=8081

要定义默认端口数,请将此默认属性添加到您的pom文件中:

To define a default port numer, add this default property to your pom file:

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

如果您需要更高级的方法来确定端口号,您需要将jetty嵌入主要班级。

If you need any more advanced method for determining the port number, you will need to embed jetty in your main class.

这篇关于如何使用maven运行多个jetty实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆