【问题标题】:exclude WEB-INF from a maven generated war从 Maven 生成的战争中排除 WEB-INF
【发布时间】:2014-06-11 21:10:32
【问题描述】:

如何防止 WEB-INF 目录包含在 .war 包中?

这不起作用。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1</version>
    <configuration>
        <warSourceExcludes>WEB-INF/**</warSourceExcludes>
    </configuration>
</plugin>

这也不起作用。

        <warSourceExcludes>WEB-INF</warSourceExcludes>

【问题讨论】:

    标签: maven web-applications war web-inf


    【解决方案1】:

    我倾向于说 WEB-INF 不是 source 目录的一部分,而是被视为 resource

    因此,您应该尝试使用 webResource 属性:

    https://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html

    类似:

            <configuration>
              <webResources>
                <resource>
                  <!-- this is relative to the pom.xml directory -->
                  <directory>resource2</directory>
                  <!-- the list has a default value of ** -->
                  <excludes>
                    <exclude>WEB-INF</exclude>
                  </excludes>
                </resource>
              </webResources>
            </configuration>
    

    【讨论】:

      【解决方案2】:

      因为它是一个只有 .js、.css 和 .html 的静态 HTML 站点,所以我切换到只生成 META-INF 的 rar 包格式。然后我添加了这个:

      <project>
        ...
        <build>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-war-plugin</artifactId>
              <version>2.3</version>
              <configuration>
                <archive>
                  <addMavenDescriptor>false</addMavenDescriptor>
                </archive>
              </configuration>
            </plugin>
          </plugins>
        </build>
        ...
      </project>
      

      【讨论】:

        猜你喜欢
        • 2016-09-13
        • 2010-12-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-11
        • 2014-01-05
        • 2017-10-19
        • 2014-12-31
        相关资源
        最近更新 更多