mvn tomcat:run 不启动 Tomcat
Posted
技术标签:
【中文标题】mvn tomcat:run 不启动 Tomcat【英文标题】:mvn tomcat:run doesn't start Tomcat 【发布时间】:2010-11-13 13:07:39 【问题描述】:我正在尝试使用 maven 及其 tomcat 插件部署和运行我的 web 应用程序。
我已经在项目的 pom.xml 中设置了它,但是当我从命令行调用它时:
mvn tomcat:run
我得到的只是:
[root@ovz6022 trunk]# mvn -e tomcat:run
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.gotbrains.breeze:breeze:jar:1.0
[INFO] task-segment: [tomcat:run]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing tomcat:run
[INFO] [resources:resources execution: default-resources]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/trunk/src/main/resources
[INFO] [compiler:compile execution: default-compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [tomcat:run execution: default-cli]
[INFO] Skipping non-war project
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24 seconds
[INFO] Finished at: Thu Jul 23 14:34:31 MDT 2009
[INFO] Final Memory: 7M/14M
[INFO] ------------------------------------------------------------------------
仅此而已。 Tomcat 尚未启动,但我在这里没有看到任何错误。
有人知道发生了什么吗?
【问题讨论】:
【参考方案1】:如前所述,您应该使用战争包装。但是,如果您因为使用 OSGI 或其他原因而无法部署,您可以使用 ignorePackaging 选项告诉 Tomcat 插件部署,即使它不是战争打包:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<ignorePackaging>true</ignorePackaging>
【讨论】:
或使用-Dtomcat.ignorePackaging=true
【参考方案2】:
线索就在这条线上:
[INFO] Skipping non-war project
tomcat:run 目标旨在与战争项目一起使用,我猜你的是一个 jar 项目。
您需要将项目的打包更改为war,您可能还需要为war提供一些额外的配置才能真正做任何事情。
注意:我建议在您的 jar 项目中添加一个单独的 war 项目,然后将 jar 作为依赖项添加到 war。
【讨论】:
没有帮助的答案。向下滚动查看添加到 pom.xml 并修复问题的简单选项。【参考方案3】:如果您正在使用 Roo,并且尚未调用控制器命令,那么您的配置尚未设置为生成 WAR 文件。
【讨论】:
以上是关于mvn tomcat:run 不启动 Tomcat的主要内容,如果未能解决你的问题,请参考以下文章
Maven启动tomcat7:run运行异常:org.apache.catalina.LifecycleException: Failed to start component