Maven的tomcat插件tomcat-maven-plugin

本文详细介绍如何通过Maven将项目部署到Tomcat服务器上,包括创建Maven Web工程、配置Tomcat用户权限、设置Maven环境、添加tomcat-maven-plugin插件以及使用maven-antrun-plugin进行Ant脚本编写。

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

第一步创建maven web工程。
Maven的tomcat插件tomcat-maven-plugin

第二步,设置tomcat-users.xml。
<tomcat-users>
   <role rolename="manager"/>
   <user username="admin" password="admin" roles="manager"/>
</tomcat-users>

第三步,配置maven的settings.xml。
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
      <localRepository>D:/maven/repository</localRepository>
      <servers>
      <server>
         <id>myserver</id>
         <username>admin</username>
         <password>admin</password>
      </server>
   </servers>
</settings>

第四步,pom.xml中添加 tomcat-maven-plugin插件。
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<configuration>
<url>http://127.0.0.1:8080/manager/html</url>
<server>myserver</server>
<URIEncoding>UTF-8</URIEncoding>
</configuration>
</plugin>
</plugins>

第五步,运行命令tomcat:run。
Maven的tomcat插件tomcat-maven-plugin

Maven的tomcat插件tomcat-maven-plugin

第六步,验证一下。
Maven的tomcat插件tomcat-maven-plugin

另外,还可以加入maven-antrun-plugin这样的插件,可以编写ant脚本。
<!-- ant插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>copy</id>
<phase>compile</phase>
<configuration>
<target>
<!-- ant script here begin -->

<copy todir="E:/数据报表测试20120509/ReportModuleConfig"
overwrite="true">
<fileset dir="${basedir}/ui/" />
</copy>
<!-- <copy todir="${basedir}/target/classes/com/gw/commodity/mapper" 
overwrite="true"> <fileset dir="${basedir}/src/main/java/com/gw/commodity/mapper" 
/> </copy> -->
<!-- ant script here end -->
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值