【发布时间】:2012-05-21 16:19:43
【问题描述】:
我正在使用 jetty maven 插件来部署一些战争。 我有2个模块: moduleA.war 在端口 8180 moduleB.war 在端口 8380
当我使用 maven jetty 插件部署战争时,两个 web 应用程序都试图在端口 8180 上运行,即使我正在为这两个应用程序设置连接器。这是我的 pom 配置:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.1.3.v20100526</version>
<configuration>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8180</port>
<name>instance_8180</name>
</connector>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8380</port>
<name>instance_8380</name>
</connector>
</connectors>
<contextHandlers>
<!-- <contextHandler implementation="org.mortbay.jetty.plugin.JettyWebAppContext"> -->
<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
<war>/${project.build.directory}/user-mgmt-web-1.0-SNAPSHOT.war</war>
<contextPath>/user-mgmt-web</contextPath>
<connectorNames>
<item>instance_8180</item>
</connectorNames>
</contextHandler>
<!-- <contextHandler implementation="org.mortbay.jetty.plugin.JettyWebAppContext"> -->
<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
<war>/${project.build.directory}/services-web-1.0-SNAPSHOT.war</war>
<contextPath>/services-web</contextPath>
<connectorNames>
<item>instance_8380</item>
</connectorNames>
</contextHandler>
</contextHandlers>
<stopPort>80</stopPort>
<stopKey>stop</stopKey>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>stop</goal>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
我想知道如何让部署的第二个 webapp 从其分配的端口开始。 当我运行它时,当容器完成初始化第二个 webapp 时,我得到一个地址已在使用中的错误。
阿萨内
【问题讨论】:
-
感谢您的回复,我是使用堆栈溢出的新手。我会回去接受我之前问题的答案。
-
如果您查看我的 pom,我正在使用上下文处理程序,并且为每个上下文分配一个带有端口号的连接器。这有意义还是我错过了什么?
-
有道理。我不以这种方式运行我的项目,我使用单个实例并且只是将其作为建议提供。听起来您打算在多个端口上运行它并且您打算这样做。如果以后这个问题仍然存在,我可能会更深入地研究它,看看我是否能提供帮助。祝你好运!
标签: maven plugins deployment jetty