tomcat7-maven-plugin插件把web应用一键式的部署到一个远程的tomcat中

本文介绍如何使用Maven插件在Apache Tomcat上部署应用程序。主要内容包括配置pom.xml文件、设置Tomcat用户权限及通过命令行进行部署。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. http://tomcat.apache.org/maven-plugin.html
  2. http://stackoverflow.com/questions/16230666/failed-to-execute-goal-org-codehaus-mojotomcat-maven-plugin1-1deploy-default
NOTE:  url 结尾必须是/text, 不能是/html 或者 / ,  暂时不知道为什么.
<url>http://localhost:8080/manager/ text</url>

The following way works for me.

  1. Please change your pom.xml to include

    <project>
        ...
        <build>    
            <plugins>    
            ....
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.1</version>
                    <configuration>
                        <url>http://localhost:8080/manager/text</url>
                        <server>my-tomcat</server>
                        <path>/myapp</path>
                    </configuration>
                </plugin>
            </plugins>
            ...
        </build>
        ...
    </project>
    
  2. Make sure your Tomcat 7 server have the following lines on TOMCAT_HOME/conf/tomcat-users.xml:

    <!-- Role to manage WAR files via HTML /manager. The name should be as is! -->
    <role rolename="manager-gui"/>
    <!-- Role to manage WAR files via script like Maven. The name should be as is! -->
    <role rolename="manager-script"/>
    
    <!-- One user cannot have manager-gui and manager-script roles -->
    <user username="managerGui" password="managerPwd" roles="manager-gui"/>
    <user username="manager" password="managerPwd" roles="manager-script"/>
    
  3. Configure your USER_HOME/.m2/settings.xml to include the password.

    <settings>
        ...
        <servers>
            ...
            <server>
                <id>my-tomcat</id>
                <username>manager</username>
                <password>managerPwd</password>
            </server>
        </servers>
    
    </settings>
    
  4. Deploy using mvn tomcat7:redeploy

Read more on http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html


  1. https://yq.aliyun.com/articles/47159
  2. http://www.cnblogs.com/yezhenhan/archive/2012/07/17/2594684.html


The following way works for me.

  1. Please change your pom.xml to include

    <project>
        ...
        <build>    
            <plugins>    
            ....
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.1</version>
                    <configuration>
                        <url>http://localhost:8080/manager/text</url>
                        <server>my-tomcat</server>
                        <path>/myapp</path>
                    </configuration>
                </plugin>
            </plugins>
            ...
        </build>
        ...
    </project>
    
  2. Make sure your Tomcat 7 server have the following lines on TOMCAT_HOME/conf/tomcat-users.xml:

    <!-- Role to manage WAR files via HTML /manager. The name should be as is! -->
    <role rolename="manager-gui"/>
    <!-- Role to manage WAR files via script like Maven. The name should be as is! -->
    <role rolename="manager-script"/>
    
    <!-- One user cannot have manager-gui and manager-script roles -->
    <user username="managerGui" password="managerPwd" roles="manager-gui"/>
    <user username="manager" password="managerPwd" roles="manager-script"/>
    
  3. Configure your USER_HOME/.m2/settings.xml to include the password.

    <settings>
        ...
        <servers>
            ...
            <server>
                <id>my-tomcat</id>
                <username>manager</username>
                <password>managerPwd</password>
            </server>
        </servers>
    
    </settings>
    
  4. Deploy using mvn tomcat7:redeploy

Read more on http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值