0

我使用 Maven Tomcat 插件运行 Maven 目标“全新安装”:

<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>

并得到错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logBeanFactoryPostProcessor' defined in URL [jar:file:/D:/projects/MainSpringProject/SpringSubProject/General/target/General-1.0-SNAPSHOT.jar!/com/springproject/ioc/LogBeanFactoryPostProcessor.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: com.noveogroup.springtrainig.service.ApplicationService [Xlint:invalidAbsoluteTypeName]

如果我运行 maven“clean package”并手动部署到 tomcat 中,我会注意你没有错误!,但是当我与 tomcat-maven-plugin 相同时,我得到了这样的错误。可能是什么问题?

4

1 回答 1

0

我建议从更简单(并且更新的)配置开始:

  <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:

mvn tomcat7:run

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

于 2013-11-05T18:51:35.240 回答