maven常用插件之tomcat

本文介绍如何在Maven项目中集成Tomcat6和Tomcat7,包括配置repository、添加插件以及设置访问路径等步骤,最后通过命令实现项目的运行。

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

源:

评:

maven常用插件之tomcat
插件作用:在maven项目中,使用tomcat6、tomcat7运行maven项目。

1.声明repository及pluginRepository

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<repositories>
    <repository>
      <id>people.apache.snapshots</id>
      <url>http://repository.apache.org/content/groups/snapshots-group/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>
 
  <pluginRepositories>
    <pluginRepository>
      <id>apache.snapshots</id>
      <name>Apache Snapshots</name>
      <url>http://repository.apache.org/content/groups/snapshots-group/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>


2.添加tomcat6、tomcat7插件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<plugins>
  ...
    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat6-maven-plugin</artifactId>
      <version>2.0-SNAPSHOT</version>
      <configuration>
        <!--
           默认访问路径为:http://localhost:8080/${project.name}
           下面指定访问路径为: http://localhost:8080
        -->
        <path>/</path>
      </configuration>
    </plugin>
    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <version>2.0-SNAPSHOT</version>
      <configuration>
        <path>/</path>
      </configuration>
    </plugin>
  ...
  </plugins



3.在settings.xml文件里添加groupId

?
1
2
3
4
5
<pluginGroups>
    ....
    <pluginGroup>org.apache.tomcat.maven</pluginGroup>
    ....
</pluginGroups>


最后执行下面命令,就可以在tomcat里运行maven项目了

mvn tomcat6:run
mvn tomcat7:run
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值