首页 文章

在Jetty中部署多个战争

提问于
浏览
0

我正在使用jetty maven插件来部署一些战争 . 我有2个模块:端口8180的moduleA.war,端口8380的moduleB.war

当我使用maven jetty插件部署战争时,两个webapp都试图在端口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时,我得到一个已经在使用中的地址错误 .

阿萨

1 回答

  • 0

    我认为具有两个不同端口的两个不同模块仅在多个实例中工作,在您的情况下,仅第一个端口没有被激活设置第一个端口的空闲超时 .

    <port>8180</port>
    <maxIdleTime>"put your time"</maxIdleTime>
    

    然后启动另一个端口 .

    如果上面没有工作,请尝试下面这个

    在您的jetty.xml中添加新连接器

    <!-- original connector on port 8080 -->
    <Call name="addConnector">
      <Arg>
          <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
            <Set name="host"><Property name="jetty.host" /></Set>
            <Set name="port"><Property name="jetty.port" default="8080"/></Set>
            <Set name="maxIdleTime">300000</Set>
            <Set name="Acceptors">2</Set>
            <Set name="statsOn">false</Set>
            <Set name="confidentialPort">8443</Set>
        <Set name="lowResourcesConnections">20000</Set>
        <Set name="lowResourcesMaxIdleTime">5000</Set>
          </New>
      </Arg>
    </Call>
    
    <!-- new connector on port 8081 --> 
    <Call name="addConnector">
      <Arg>
          <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
            <Set name="host"><Property name="jetty.host" /></Set>
            <Set name="port"><Property name="jetty.port" default="8081"/></Set>
            <Set name="maxIdleTime">300000</Set>
            <Set name="Acceptors">2</Set>
            <Set name="statsOn">false</Set>
        <Set name="lowResourcesConnections">20000</Set>
        <Set name="lowResourcesMaxIdleTime">5000</Set>
          </New>
      </Arg>
    </Call>
    

相关问题