如何排除JAR被添加到WAR文件中 [英] How to exclude Jars from being added in the WAR file

查看:152
本文介绍了如何排除JAR被添加到WAR文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我将一些jar设置为项目依赖关系。这个jar添加为用户库。当我在JBoss AS7中运行应用程序时,我正在使用由JBoss服务器提供的JSF实现,我已经从模块中复制了这些JSF jar,并创建了一个新的用户库,即JBoss JSF。该库已被用于在Eclipse中创建JSF 2动态Web项目。现在,当我将它导出为WAR文件时,这些jsf jar会自动被复制并添加到战争的 / WEB-INF / lib 中。我不希望这些文件被添加,因为它们已经存在于容器中。



有没有办法?



有关详细信息,这是.classpath文件的内容:

 <?xml版本=1.0encoding =UTF-8?> 
< classpath>
< classpathentry kind =srcpath =src / common/>
< classpathentry kind =srcpath =src / service/>
< classpathentry kind =srcpath =src / web/>
< classpathentry kind =srcpath =src / persistent/>
< classpathentry kind =srcpath =src / dao/>
< classpathentry kind =conpath =org.eclipse.jdt.launching.JRE_CONTAINER / org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType / jre7>
<属性>
< attribute name =owner.project.facetsvalue =java/>
< / attributes>
< / classpathentry>
< classpathentry kind =conpath =org.eclipse.jst.j2ee.internal.web.container/>
< classpathentry kind =conpath =org.eclipse.jst.j2ee.internal.module.container/>
< classpathentry kind =conpath =org.eclipse.jdt.USER_LIBRARY / JBoss JSF>
<属性>
< attribute name =owner.project.facetsvalue =jst.jsf/>
< / attributes>
< / classpathentry>
< classpathentry kind =conpath =org.eclipse.jdt.USER_LIBRARY / JBoss Servlet/>
< classpathentry kind =conpath =org.eclipse.jdt.USER_LIBRARY / JBoss log4j/>
< classpathentry kind =outputpath =build / classes/>
< / classpath>

我的应用程序的部署程序集:

解决方案

尝试这个


  1. 打开项目属性

  2. 选择部署程序集

  3. 选择库您需要从战争文件中排除,然后单击删除。
    您选择的Jars将从War文件中删除

或尝试向.classpath文件添加一个属性

 < classpathentry kind =conpath =org.eclipse.jdt.USER_LIBRARY / JBoss JSF> 

<属性>

< attribute name =owner.project.facetsvalue =jst.jsf/>

< attribute name =org.eclipse.jst.component.nondependencyvalue =/>

< / attributes>


In the my application I have set some jars as project dependency. This jars are added as User Library. As I am running the application in JBoss AS7 and I am using the JSF implementation which is provided by the JBoss server, I have copied those JSF jars from the module and create a new User Library namely JBoss JSF. This library has been used to create JSF 2 Dynamic Web Project in Eclipse. Now when I am exporting it as a WAR file, those jsf jars are automatically being copied and added in /WEB-INF/lib of the war. I don't want that these files are added as they are already present in the container.

Is there any way to do it?

For more information, this is the content of the .classpath file:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src/common"/>
    <classpathentry kind="src" path="src/service"/>
    <classpathentry kind="src" path="src/web"/>
    <classpathentry kind="src" path="src/persistent"/>
    <classpathentry kind="src" path="src/dao"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7">
        <attributes>
            <attribute name="owner.project.facets" value="java"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
    <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JBoss JSF">
        <attributes>
            <attribute name="owner.project.facets" value="jst.jsf"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JBoss Servlet"/>
    <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JBoss log4j"/>
    <classpathentry kind="output" path="build/classes"/>
</classpath>

The Deployment Assembly of my application:

解决方案

Try this

  1. Open Project properties
  2. Select Deployment Assembly
  3. Select libraries that you need to exclude from the war file then click Remove . Jars you selected will be removed from the War file

or try to add one more attribute to the .classpath file

<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JBoss JSF">

   <attributes>

    <attribute name="owner.project.facets" value="jst.jsf"/>

    <attribute name="org.eclipse.jst.component.nondependency" value=""/> 

  </attributes>

这篇关于如何排除JAR被添加到WAR文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆