这里以安装tomcat依赖为例
1, 访问maven公共仓库
2,搜索tomcat
3, 右侧点击Plugin
选择:Apache Tomcat Maven Plugin :: Tomcat 7.x
选择版本,这里我选择2.2
选择maven,将<dependency>中的内容copy到pom.xml中的<build>里面
添加完毕pom.xml如下
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.itheima</groupId>
<artifactId>Demo</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>demo2</artifactId>
<packaging>war</packaging>
<name>demo2 Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>demo2</finalName>
<plugins><!--tomcat插件-->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>80</port>
<path>/</path>
<uriEncoding>UTF-8</uriEncoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
点击M图标,会自动取仓库中下载tomcat的jar包
即安装完毕