tomcat-maven-plugin在pom.xml中的配置
https://blog.csdn.net/TSDDragon/article/details/38686277
1、使用tomcat-maven-plugin需要在pom.xml文件中project>build节点下添加以下代码:
<pluginManagement> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat6-maven-plugin</artifactId> <version>2.3-SNAPSHOT</version> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.3-SNAPSHOT</version> </plugin> </plugins> </pluginManagement>2、添加仓库信息,保证maven可以从仓库中下载到tomcat-maven-plugin插件
(a)在project>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>
(b)在project>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>
正确的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>
-
<groupId>MavenHelloWorld
</groupId>
-
<artifactId>MavenHelloWorld
</artifactId>
-
<packaging>war
</packaging>
-
<version>0.0.1-SNAPSHOT
</version>
-
<name>MavenHelloWorld 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>
-
<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>
-
<build>
-
<finalName>MavenHelloWorld
</finalName>
-
<pluginManagement>
-
<plugins>
-
<plugin>
-
<groupId>org.apache.tomcat.maven
</groupId>
-
<artifactId>tomcat6-maven-plugin
</artifactId>
-
<version>2.0-SNAPSHOT
</version>
-
<configuration>
-
<url>http://localhost:8080/manager/text
</url>
-
<server>tomcat
</server>
-
</configuration>
-
</plugin>
-
<plugin>
-
<groupId>org.apache.tomcat.maven
</groupId>
-
<artifactId>tomcat7-maven-plugin
</artifactId>
-
<version>2.0-SNAPSHOT
</version>
-
<configuration>
-
<url>http://localhost:8080/manager/text
</url>
-
<server>tomcat
</server>
-
</configuration>
-
</plugin>
-
</plugins>
-
</pluginManagement>
-
</build>
-
</project>