maven常用插件之tomcat

源:

评:

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

猜你喜欢

转载自mauersu.iteye.com/blog/1828354