Java 无法使用maven插件在tomcat中启动Spring应用程序

Java 无法使用maven插件在tomcat中启动Spring应用程序,java,spring,maven,tomcat,plugins,Java,Spring,Maven,Tomcat,Plugins,我使用maven Tomcat插件运行maven goals“干净安装”: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <configuration> <url>http://localhost:8080/manager/html<

我使用maven Tomcat插件运行maven goals“干净安装”:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>

    <configuration>
        <url>http://localhost:8080/manager/html</url>
        <server>TomcatServer</server>
        <failOnError>false</failOnError>
        <path>/spring-training</path>
        <fork>true</fork>
    </configuration>
    <executions>
        <execution>
            <id>01-start-tomcat</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
        <execution>
            <id>02-stop-tomcat</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>shutdown</goal>
            </goals>
        </execution>
    </executions>
</plugin>

请注意如果我运行maven“clean package”并手动部署到tomcat中,则不会出现任何错误,但当我使用tomcat maven插件时,会出现这样的错误。问题可能是什么?

我建议从一个更简单(且更及时)的配置开始:

  <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
      <port>9090</port>
      <useTestClasspath>true</useTestClasspath>
      <path>/</path>
    </configuration>
  </plugin>

请注意,这将启动一个嵌入式tomcat服务器,确保您不依赖于在构建机器上安装tomcat的位置。

您似乎有多个模块,因此我怀疑从maven部署时有不同的类路径(旧的、不完整的等)。你能分享完整的maven配置吗?
  <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
      <port>9090</port>
      <useTestClasspath>true</useTestClasspath>
      <path>/</path>
    </configuration>
  </plugin>
mvn tomcat7:run