简体   繁体   English

mvn tomcat:run没有启动Tomcat

[英]mvn tomcat:run doesn't start Tomcat

I am trying to deploy and run my webapplication using maven and its tomcat plugin. 我正在尝试使用maven及其tomcat插件部署和运行我的webapplication。

I have set it up in project's pom.xml, but when I'm calling it from command line: 我在项目的pom.xml中设置了它,但是当我从命令行调用它时:

mvn tomcat:run

all that I get is: 我得到的只是:

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

And that's all. 就这样。 Tomcat hasn't been launched but I don't see any errors here. Tomcat还没有发布,但我没有看到任何错误。

Does anybody knows what's happening? 有人知道发生了什么吗?

As mentioned before, you should use war packaging. 如前所述,你应该使用战争包装。 However, if you can't because you're using OSGI or some other reason, you can tell the Tomcat plugin to deploy anyway even if it isn't war packaging by using the ignorePackaging option: 但是,如果您因为使用OSGI或其他原因而无法使用,则可以通过使用ignorePackaging选项告诉Tomcat插件,即使它不是war包装也是如此:

            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat6-maven-plugin</artifactId> 
                <version>2.0</version>
                <configuration>
                    <ignorePackaging>true</ignorePackaging>

The clue is in the line: 线索在线:

[INFO] Skipping non-war project

The tomcat:run goal is intended to work with war projects, I'm guessing yours is a jar project. tomcat:run目标是用于war项目,我猜你的是一个jar项目。

You need to change the packaging of your project to war, you may also need to provide some additional configuration for the war to actually do anything. 您需要将项目的包装更改为战争,您可能还需要为战争提供一些额外的配置以实际执行任何操作。

Note: I'd recommend having a separate war project to your jar projects, then adding the jars as dependencies to the war. 注意:我建议你的jar项目有一个单独的war项目,然后将jar作为依赖项添加到war中。

如果您正在使用Roo,并且尚未调用控制器命令,那么您的配置尚未设置为生成WAR文件。

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

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