mvn tomcat7:run - How does it work?

前端 未结 1 1695
半阙折子戏
半阙折子戏 2020-12-24 06:51

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.

This is my under

相关标签:
1条回答
  • 2020-12-24 07:18

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

    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.

    0 讨论(0)
提交回复
热议问题