Maven配置覆盖内嵌tomcat虚拟映射路径

Maven配置覆盖内嵌tomcat虚拟映射路径 直接配置报错,错误提示如下:Caused by: java.lang.IllegalArgumentException: addChild:Child name '/store' is not unique原因分析:pom.xml的配置并...

直接配置报错,错误提示如下:

  • Caused by: java.lang.IllegalArgumentException: addChild:Child name '/store' is not unique
    • 原因分析:pom.xml的配置并没有覆盖tomcat/conf/server.xml中的配置,导致配置中存在多个相同配置

解决方案

  • 下载tomcat7-maven-plugin-2.2.jar.zip文件,解压并覆盖本地仓库中的tomcat7-maven-plugin-2.2.jar
    比如我的本地仓库在:D:\M2REPO\org\apache\tomcat\maven\tomcat7-maven-plugin\2.2下,那么我们只需要解压并此目录下的
    tomcat7-maven-plugin-2.2.jar覆盖此文件就ok.

pom.xml配置

<plugins>
    <!-- 指定jdk1.7编译,否则maven update 可能调整jdk -->
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
            <encoding>UTF-8</encoding>
        </configuration>
    </plugin>
    <!-- tomcat7插件。使用方式:tomcat7:run -->
    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
            <update>true</update>
            <port>8080</port>
            <uriEncoding>UTF-8</uriEncoding>
            <server>tomcat7</server>
            <!-- tomcat虚拟映射路径 -->
            <staticContextPath>/store</staticContextPath>
            <staticContextDocbase>d:/file/store/</staticContextDocbase>
            <contextReloadable>false</contextReloadable>
            <useTestClasspath>true</useTestClasspath>
        </configuration>
    </plugin>
</plugins>

参考地址

  • 发表于 2019-01-17 13:53
  • 阅读 ( 2248 )
  • 分类:默认分类

0 条评论

请先 登录 后评论
不写代码的码农
Jonny

程序猿

65 篇文章

作家榜 »

  1. 威猛的小站长 124 文章
  2. Jonny 65 文章
  3. 江南烟雨 36 文章
  4. - Nightmare 33 文章
  5. doublechina 31 文章
  6. HJ社区-肖峰 29 文章
  7. 伪摄影 22 文章
  8. Alan 14 文章