开发者

Exclude all the jar's from webapp/WEB-INF/lib

I have the third party jar's in my WEB project placed at /src/main/webapp/WEB-INF/lib/

I have mentioned the dependency for all the required JAR's in the pom.xml. Now, Since the dependencies are defined in POM, the JAR's will be automatically packed in the lib folder.

  • I want to exclude all the JAR's in the lib.
  • The Dependency JAR's should be packaged inside the lib while building the WAR

I CANT DELETE THE LIB FROM WEB-INF BECAUSE ITS USED IN LOCAL DEVELOPMENT

This is what I've tried so far:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <packagingExcludes>META-INF/context.xml</packagingExcludes>
    <webResources>
      <res开发者_StackOverflow中文版ource>
        <directory>src/main/webapp/WEB-INF/lib</directory>
        <excludes>
          <exclude>**/**</exclude>
        </excludes>
      </resource>
    </webResources>
  </configuration>
</plugin>

Any Idea?


It should be "packagingExcludes" instead of "warSourceExcludes":

<configuration>
    <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
    ....
</configuration>

From http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html :

In version 2.1-alpha-1, this was incorrectly named warSourceExcludes


Try this:

<configuration>
    <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
    ....
</configuration>

However, I do agree with Jarrod that it is bad practice to store your jars in WEB-INF/lib 'manually'. I used this before to avoid that jars coming as a dependency got packaged to be able to repackage it afterwards.


you shouldn't have anything in your WEB-INF/lib directory to begin with. If you are using Eclipse, you can tell it to build its project from the pom.xml and it will know to look in ~/.m2/repository for dependencies, Intellij IDEA does this as well. Putting dependencies in WEB-INF/lib kind of defeats the purpose of using Maven for dependency management. What happens when the dependencies in the pom.xml get out of sync version wise with those in WEB-INF/lib

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜