简体   繁体   中英

mvn tomcat:run doesn't start Tomcat

I am trying to deploy and run my webapplication using maven and its tomcat plugin.

I have set it up in project's pom.xml, but when I'm calling it from command line:

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.

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:

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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