如何用ant制作war包?(分不够可以再给)

GumPGZ 2004-08-26 01:44:53
我已经把javabean和servlet等便衣到webapp的web-inf/classes下面了
现在就是不知道怎么制作war包
而且我的项目用到了几个jar,比如class12.jar,smartupload.jar等,
在制作war包的时候这些东西也应该一并放进去吧,那么这些jar放到哪里呢?

各位前辈能给我发一个如何制作war的完整的build.xml么?现在我只会编译java文件,不知道如何制作war包,而且我的机器又狂慢,用jbuilder真是生不如死,谢谢了!

这里不方便回,会我邮箱也可以:gumpgz@gmail.com
...全文
415 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wujinpinga 2004-10-12
  • 打赏
  • 举报
回复
mark
baffling 2004-09-18
  • 打赏
  • 举报
回复
gz
GumPGZ 2004-08-26
  • 打赏
  • 举报
回复
接贴,现在就是jar是双份的,真郁闷,谢谢两位
GumPGZ 2004-08-26
  • 打赏
  • 举报
回复
谢谢二位,中文问题也搞定了,<target name="war" depends="compile" encoding="gb2312">

但是现在前两个问题不知道是怎么回事
GumPGZ 2004-08-26
  • 打赏
  • 举报
回复
我已经制作了war包,但是还有几个问题:

我的target如下:
<target name="war" depends="compile">
<war warfile="${warDir}\mlmproject.war" webxml="${webDir}\WEB-INF\web.xml">
<lib dir="${webDir}\WEB-INF\lib"/>
<classes dir="${buildDir}"/>
<fileset dir="${webDir}"/>
</war>
</target>
我确认路径都对

1.制作war包时,提示如下错误:
[war] Warning: selected war files include a WEB-INF/web.xml which will be ignored (please use webxml attribute to war task)
这个错误是什么意思?
2.在我的web-inf\classes里面有个ChangeReqEncoding.class类,使解决中文问题的filter,这个类在war包中除下了两次,同时在web-inf\lib目录下,class12.jar,smartupload.jar也都是双份
3.我的项目下有个upload目录,里面是中文的文件夹,做成war后看到的是中文乱码,在我的build.xml文件中第一行已经是:<?xml version="1.0" encoding="gb2312"?>

请问如上是什么问题?谢谢
KillAllError 2004-08-26
  • 打赏
  • 举报
回复
http://ant.apache.org/manual/CoreTasks/war.html

作这种东西简单,好好看看Ant得Manual!你说你会用Ant编译程序,看看这个网页就什么都会了

War
Description
An extension of the Jar task with special treatment for files that should end up in the WEB-INF/lib, WEB-INF/classes or WEB-INF directories of the Web Application Archive.

(The War task is a shortcut for specifying the particular layout of a WAR file. The same thing can be accomplished by using the prefix and fullpath attributes of zipfilesets in a Zip or Jar task.)

The extended zipfileset element from the zip task (with attributes prefix, fullpath, and src) is available in the War task.
umbrella1984 2004-08-26
  • 打赏
  • 举报
回复
<project name="geezer_project" default="dist" basedir=".">
<property environment="myenv" />
<property name="servletpath" value="${myenv.TOMCAT_HOME}/common/lib/servlet-api.jar" />
<property name="mysqlpath" value="c:/resin/doc/15com/WEB-INF/lib/mm.mysql-2.0.4-bin.jar" />
<property name="src" location="src"/>
<property name="build" location="build"/>
<target name="init">
<mkdir dir="${build}"/>
<mkdir dir="${build}\WEB-INF" />
<mkdir dir="${build}\WEB-INF\lib" />
<mkdir dir="${build}\WEB-INF\classes" />
</target>
<target name="compile" depends="init"
description="compile the source " >
<javac srcdir="${src}"
destdir="${build}/WEB-INF/classes"
classpath="${servletpath}:${mysqlpath}">
</javac>
</target>
<target name="war" depends="compile">
<war warfile="${build}/bookstore.war" webxml="${build}/WEB-INF/web.xml">
<lib dir="${build}/WEB-INF/lib"/>
<classes dir="${build}/WEB-INF/classes/"/>
<fileset dir="${build}"/>
</war>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >
<jar jarfile="MyProject.jar" basedir="${build}"/>
</target>
<target name="clean"
description="clean up" >
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>

上面是完整的,你搜索ANT文章,很多的。
umbrella1984 2004-08-26
  • 打赏
  • 举报
回复
jar -cvf my.war *.*

ant创建一个target,


<target name="war" depends="compile">

<war warfile="${build}/my.war" webxml="${build}/WEB-INF/web.xml">
<lib dir="${build}/WEB-INF/lib"/>
<classes dir="${build}/WEB-INF/classes/"/>
<fileset dir="${build}"/>

</war>

</target>

把build.xml拷贝到你的WEB根目录下,在改目录下执行ant -buildfile build.xml war
GumPGZ 2004-08-26
  • 打赏
  • 举报
回复
没人知道么?还是根本就没有这个功能阿

67,550

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧