
方法一:
1) 右键点击打包所用的文件(build.xxx.xml),选择Run As à 3.Ant Build…
2) 进入编辑配置页面如图1-1:选择classpath, Add External JARs…
3) 添加所需jar包即可
方法二:
将jar包拷贝到jdk\jre\lib\ext目录下.例如:如果需要servlet-api.jar,jsp-api.jar(这两个jar包在tomcat的lib目录中存在),那么可以进行如下 *** 作
将tomcat\common\lib\servlet-api.jar拷贝到jdk\jre\lib\ext目录下
将tomcat\common\lib\jsp-api.jar拷贝到jdk\jre\lib\ext目录下(jsp自定义标签库需要)
注意:
该方法导入servlet-api.jar以后对项目在Eclipse中的运行没有影响
导入jsp-api.jar以后,可以正常打包,但是在Eclipse中运行项目会报错.打完包以后将jdk\jre\lib\ext目录下的jsp-api.jar删掉,项目即可正常运行.
个人推荐用方法一
你说的是ant的构建文件build.xml吗? 如果是 只要在jar标签中添加<zipgroupfileset dir="${lib.dir}" includes="*.jar" />
例如:
<jar destfile=xxx >
<zipgroupfileset dir="${lib.dir}" includes="*.jar" /> //意思就是添加lib下所有的jar包
</jar>
抄一个例子给你,自己去领会吧。build.properties:
classpath.external=C\:\\ExadelStudio\\lib\\servlet\\2.3\\servlet.jar
build.xml:
<project name= "empty " basedir= "../ " default= "build ">
<!-- Local system paths -->
<property file= "${basedir}/ant/build.properties "/>
<!--property name= "deploy.dir " value= "${exadel.home}/tomcat/webapps "/-->
<property name= "webroot.dir " value= "${basedir}/WebContent "/>
<property name= "webinf.dir " value= "${webroot.dir}/WEB-INF "/>
<property name= "build.dir " value= "build "/>
<!-- Project settings -->
<property name= "project.distname " value= "empty "/>
<!-- classpath for Struts 1.1 -->
<path id= "compile.classpath ">
<pathelement path = "${webinf.dir}/lib/commons-beanutils.jar "/>
<pathelement path = "${webinf.dir}/lib/commons-digester.jar "/>
<pathelement path = "${webinf.dir}/lib/struts.jar "/>
<pathelement path = "${webinf.dir}/classes "/>
<pathelement path = "${classpath.external} "/>
<pathelement path = "${classpath} "/>
</path>
<!-- Check timestamp on files -->
<target name= "prepare ">
<tstamp/>
</target>
<!-- Copy any resource or configuration files -->
<target name= "resources ">
<copy todir= "${webinf.dir}/classes " includeEmptyDirs= "no ">
<fileset dir= "JavaSource ">
<patternset>
<include name= "**/*.conf "/>
<include name= "**/*.properties "/>
<include name= "**/*.xml "/>
</patternset>
</fileset>
</copy>
</target>
<!-- Normal build of application -->
<target name= "compile " depends= "prepare,resources ">
<javac srcdir= "JavaSource " destdir= "${webinf.dir}/classes ">
<classpath refid= "compile.classpath "/>
</javac>
</target>
<!-- Remove classes directory for clean build -->
<target name= "clean "
description= "Prepare for clean build ">
<delete dir= "${webinf.dir}/classes "/>
<mkdir dir= "${webinf.dir}/classes "/>
</target>
<!-- Build entire project -->
<target name= "build " depends= "prepare,compile "/>
<target name= "rebuild " depends= "clean,prepare,compile "/>
</project>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)