[英]Exclude some JARs from Web-Inf/Lib Folder
我是從Ant開始的。 我創建了一個build.xml
來生成Web項目的WAR文件,它運行正常。
然后,我做了一些更改,以從WEB-INF/lib
文件夾中排除所有* .jar,也可以正常工作。
現在我需要進行更改以排除所有JAR文件,但在WEB-INF/lib
文件夾中留下一些特殊的JAR。 這個JAR來自我創建的其他項目。
這個想法排除了所有第三方JAR,只將我自己的JAR留在WEB-INF/lib
文件夾中。
有辦法做到這一點?
我的所有Jars都以“fnet”開頭,所以也許我可以用它來創建一些規則,但我不知道怎么做
這是我的Build.xml:
<?xml version="1.0" ?>
<project name="warConLibs" default="build-war">
<target name="clean">
<delete file="c:/projweb.war"/>
<delete file="c:/projweb_sl.war"/>
</target>
<target name="build-war">
<war destfile="c:/projweb.war" webxml="./WebContent/WEB-INF/web.xml">
<fileset dir="./WebContent">
<include name="**/*.*"/>
</fileset>
<classes dir="./bin"/>
</war>
</target>
<target name="build-war-sin-libs">
<war destfile="c:/projweb_sl.war" webxml="./WebContent/WEB-INF/web.xml">
<fileset dir="./WebContent">
<include name="**/*.*"/>
<exclude name="**/*.jar"/>
</fileset>
<classes dir="./bin"/>
</war>
</target>
</project>
要排除一個jar文件的正確方法是在給定的文檔 。 如果有人遇到同樣的問題,他們可以參考這個鏈接。
這個例子來自文檔,這里我們從lib
中刪除jdbc1.jar
Assume the following structure in the project's base directory:
thirdparty/libs/jdbc1.jar
thirdparty/libs/jdbc2.jar
build/main/com/myco/myapp/Servlet.class
src/metadata/myapp.xml
src/html/myapp/index.html
src/jsp/myapp/front.jsp
src/graphics/images/gifs/small/logo.gif
src/graphics/images/gifs/large/logo.gif
then the war file myapp.war created with
<war destfile="myapp.war" webxml="src/metadata/myapp.xml">
<fileset dir="src/html/myapp"/>
<fileset dir="src/jsp/myapp"/>
<lib dir="thirdparty/libs">
<exclude name="jdbc1.jar"/>
</lib>
<classes dir="build/main"/>
<zipfileset dir="src/graphics/images/gifs"
prefix="images"/>
</war>
will consist of
WEB-INF/web.xml
WEB-INF/lib/jdbc2.jar
WEB-INF/classes/com/myco/myapp/Servlet.class
META-INF/MANIFEST.MF
index.html
front.jsp
images/small/logo.gif
images/large/logo.gif
您可能想再次閱讀有關war
Ant任務的信息: https : //ant.apache.org/manual/Tasks/war.html
正確的語法是:
<war destfile="..." webxml="...">
<lib dir="WebContent/WEB-INF/lib">
<include name="fnet*.jar"/>
</lib>
<classes dir="bin"/>
</war>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.