相关疑难解决方法(0)

tomcat7-maven-plugin:运行多个webapps但端口8080已经在使用中

我正在尝试使用tomcat7-maven-plugin设置嵌入式tomcat容器,pre-integration-test同步运行webapps ,运行集成测试,然后关闭tomcat post-integration-test.该项目是一个多模块Maven项目(包含app1,app2等等).父母pom.xml看起来像以下,

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <version>2.1</version>
      <configuration>
        <contextFile>path/to/context.xml</contextFile>
        <tomcatUsers>path/to/tomcat-users.xml</tomcatUsers>
        <fork>true</fork>
      </configuration>
      <executions>
        <execution>
          <id>tomcat-run</id>
          <goals>
            <goal>run</goal>
          </goals>
          <phase>pre-integration-test</phase>
        </execution>
        <execution>
          <id>tomcat-shutdown</id>
          <goals>
            <goal>shutdown</goal>
          </goals>
          <phase>post-integration-test</phase>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

然后我就跑了mvn clean integration-test --projects=app1,app2.当第二个应用程序开始,我得到的java.net.BindException,

SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-8080"]
java.net.BindException: Address already in use <null>:8080
    at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:406)
    at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:610)
    at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:429)
    at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)
    at org.apache.catalina.connector.Connector.initInternal(Connector.java:981) …
Run Code Online (Sandbox Code Playgroud)

java web-applications maven tomcat7 embedded-tomcat-7

6
推荐指数
1
解决办法
1万
查看次数