2014-06-11 43 views
0

如何阻止.war包中包含WEB-INF目录?从Maven生成的战争中排除WEB-INF

这不起作用。

<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> 

回答

0

因为它是一个静态的HTML网站,只有.js文件,的CSS和.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> 
0

我是倾斜的说,WEB-INF不是目录的一部分,但被认为是资源

因此,你应该尝试用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> 
+0

这似乎没有办法。 – user3731460