How to exclude jars from ear

别来无恙 提交于 2019-12-11 08:47:39

问题


I am bundling EAR from a WAR file. The JARS are placed both in WARFile/WEB-INF/lib folder as well as EARFile/lib folder with duplication.

Do we need the JARS again in EARFile/lib folder inspite of having in WARFile/WEB-INF/lib?

If we do not need in EAR/lib filder, How can we remove them? The EAR file size became double due to duplication JARs presence in both WAR and EAR.

Please help me.

Thanks


回答1:


Good read here on "skinny" wars. Basically, you put the jars in the ear, but not the war files:

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




回答2:


You have to define the dependency to your war project in the following way:

<dependency>
  <groupId>${project.groupId}</groupId>
  <artifactId>xyz-web</artifactId>
  <version>${project.version}</version>
  <type>war</type>
</dependency>

and furthermore you have to configure the ear plugin like the following:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <configuration>
      <version>6</version>
      <modules>
        <!-- Register our War as a web module, and set the context root -->
        <webModule>
          <groupId>${project.groupId}</groupId>
          <artifactId>xyz-web</artifactId>
          <contextRoot>/xyz</contextRoot>
        </webModule>
      </modules>
    </configuration>
  </plugin>


来源:https://stackoverflow.com/questions/9500289/how-to-exclude-jars-from-ear

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!