mvn tomcat7:run-如何运作? [英] mvn tomcat7:run - How does it work?

查看:720
本文介绍了mvn tomcat7:run-如何运作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想了解一下,因为我从另一个问题中获得了代码,并且工作正常,但是我不了解此操作的流程.

I just want to understand, because I got the code from another question, and it's working fine, but I don't understand the flow of this operation.

这是我对使用mvn tomcat7:Tomcat的Tomcat 7的Apache Maven Tomcat插件的理解:

This is my understanding of Apache Maven Tomcat plugin for Tomcat 7, when using mvn tomcat7:run with following configuration:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0-SNAPSHOT</version>
    <configuration>
        <path>/${project.build.finalName}</path>
    </configuration>
</plugin>

它会使用默认配置创建一个新的Tomcat 7实例,然后在该实例中将项目war文件用作已部署的项目,对吗,如果我输入错了,请更正我,或者有人请向我描述此过程的工作方式,谢谢.

It creates a new Tomcat 7 instance with default configuration, then use project war file as a deployed project in this instance, am I right, please correct me if I am wrong, or someone please describe to me how this process is working, thanks in advance.

推荐答案

pom.xml取决于Tomcat的捆绑软件. Maven下载它们,然后该插件通过Web项目启动嵌入式Tomcat实例.

pom.xml of the tomcat7-maven-plugin depends on Tomcat's bundles. Maven download them and the plugin starts an embedded Tomcat instance with the webproject.

mvn -X tomcat7:run打印配置.一些有趣的部分:

mvn -X tomcat7:run prints the configuration. Some interesting parts:

[INFO] Preparing tomcat7:run
[DEBUG] (s) resources = [Resource {targetPath: null, filtering: false, 
    FileSet {directory: /workspace/webtest1/src/main/resources, 
    PatternSet [includes: {}, excludes: {}]}}]
...
[DEBUG] (f) additionalConfigFilesDir = /workspace/webtest1/src/main/tomcatconf
[DEBUG] (f) configurationDir = /workspace/webtest1/target/tomcat
...
[DEBUG] (f) path = /webtest1
...
[DEBUG] (f) port = 8080
[DEBUG] (f) project = ...:webtest1:0.0.1-SNAPSHOT @ /workspace/webtest1/pom.xml
...
[DEBUG] (f) warSourceDirectory = /workspace/webtest1/src/main/webapp
...
[INFO] Creating Tomcat server configuration at /workspace/webtest1/target/tomcat
...
[DEBUG] adding classPathElementFile file:/workspace/webtest1/target/classes/
[DEBUG] add dependency to webapploader org.slf4j:slf4j-api:1.5.6:compile
...

warSourceDirectory指向src(而不是target),因此它作为通常的动态Web项目运行,您可以更改JSP,HTML并将其立即显示.因此,target/tomcat/webapps文件夹为空.

warSourceDirectory points to src (not target), so it runs as an usual dynamic web project, you could change your JSPs, HTMLs and it will visible immediately. Because of that the target/tomcat/webapps folder is empty.

v1.2站点包含比2.0-SNAPSHOT站点有关配置的更详细的文档:

The site of v1.2 contains a more detailed documentation than the site of 2.0-SNAPSHOT about configuration: http://mojo.codehaus.org/tomcat-maven-plugin/plugin-info.html.

这篇关于mvn tomcat7:run-如何运作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆