繁体   English   中英

无法使用Maven插件在Tomcat中启动Spring应用程序

[英]Can not start Spring application in tomcat with maven plugin

我使用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“清包”,并手动部署到Tomcat 没有错误! ,但是当我与tomcat-maven-plugin相同时,会出现此类错误。 可能是什么问题?

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

  <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的位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM