tomcat-maven-plugin在pom.xml中的配置

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节点下加如下配置信息

  1. <repository>
  2. <id>people.apache.snapshots</id>
  3. <url>
  4. http://repository.apache.org/content/groups/snapshots-group/
  5. </url>
  6. <releases>
  7. <enabled>false</enabled>
  8. </releases>
  9. <snapshots>
  10. <enabled>true</enabled>
  11. </snapshots>
  12. </repository>

(b)在project>pluginRepositories下添加如下配置信息

  1. <pluginRepository>
  2. <id>apache.snapshots</id>
  3. <name>Apache Snapshots</name>
  4. <url>
  5. http://repository.apache.org/content/groups/snapshots-group/
  6. </url>
  7. <releases>
  8. <enabled>false</enabled>
  9. </releases>
  10. <snapshots>
  11. <enabled>true</enabled>
  12. </snapshots>
  13. </pluginRepository>

正确的pom.xml文件为:

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  3. <modelVersion>4.0.0</modelVersion>
  4. <groupId>MavenHelloWorld</groupId>
  5. <artifactId>MavenHelloWorld</artifactId>
  6. <packaging>war</packaging>
  7. <version>0.0.1-SNAPSHOT</version>
  8. <name>MavenHelloWorld Maven Webapp</name>
  9. <url>http://maven.apache.org</url>
  10. <dependencies>
  11. <dependency>
  12. <groupId>junit</groupId>
  13. <artifactId>junit</artifactId>
  14. <version>3.8.1</version>
  15. <scope>test</scope>
  16. </dependency>
  17. </dependencies>
  18. <repositories>
  19. <repository>
  20. <id>people.apache.snapshots</id>
  21. <url>
  22. http://repository.apache.org/content/groups/snapshots-group/
  23. </url>
  24. <releases>
  25. <enabled>false</enabled>
  26. </releases>
  27. <snapshots>
  28. <enabled>true</enabled>
  29. </snapshots>
  30. </repository>
  31. </repositories>
  32. <pluginRepositories>
  33. <pluginRepository>
  34. <id>apache.snapshots</id>
  35. <name>Apache Snapshots</name>
  36. <url>
  37. http://repository.apache.org/content/groups/snapshots-group/
  38. </url>
  39. <releases>
  40. <enabled>false</enabled>
  41. </releases>
  42. <snapshots>
  43. <enabled>true</enabled>
  44. </snapshots>
  45. </pluginRepository>
  46. </pluginRepositories>
  47. <build>
  48. <finalName>MavenHelloWorld</finalName>
  49. <pluginManagement>
  50. <plugins>
  51. <plugin>
  52. <groupId>org.apache.tomcat.maven</groupId>
  53. <artifactId>tomcat6-maven-plugin</artifactId>
  54. <version>2.0-SNAPSHOT</version>
  55. <configuration>
  56. <url>http://localhost:8080/manager/text</url>
  57. <server>tomcat</server>
  58. </configuration>
  59. </plugin>
  60. <plugin>
  61. <groupId>org.apache.tomcat.maven</groupId>
  62. <artifactId>tomcat7-maven-plugin</artifactId>
  63. <version>2.0-SNAPSHOT</version>
  64. <configuration>
  65. <url>http://localhost:8080/manager/text</url>
  66. <server>tomcat</server>
  67. </configuration>
  68. </plugin>
  69. </plugins>
  70. </pluginManagement>
  71. </build>
  72. </project>


原文地址:https://www.cnblogs.com/sunny3158/p/15378496.html