从 gwt-project 创建一个 .war 文件 [英] create a .war file from gwt-project

查看:24
本文介绍了从 gwt-project 创建一个 .war 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Eclipse 中从我的 gwt 项目创建 .war 文件?

How do I create a .war-file from my gwt-project in eclipse?

推荐答案

我一直使用 Ant 构建文件,所以项目一键编译打包成war.

I always use Ant build file, so the project gets compiled and packaged as a war with one click.

向您的项目添加一个包含以下内容的 xml 文件:

Add an xml-file to your project with the following content:

<project name="test" basedir="." default="default">
<property name="src.dir" value="src" />
<property name="build.dir" value="war" />
<path id="compile.classpath">
    <fileset dir="${build.dir}/WEB-INF/lib">
        <include name="**/*.jar" />
        <include name="**/*.xml" />
    </fileset>
</path>

<target name="default" depends="gwtc, buildwar,deploy">
</target>

<target name="gwtc" description="GWT compile to JavaScript">
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
        <classpath>
            <pathelement location="${src.dir}" />
            <path refid="compile.classpath" />
        </classpath>
        <arg line="-logLevel INFO" />
        <jvmarg value="-Xmx1024M" />
        <arg value="YourProject.EntryPointClass" />
    </java>
</target>

<target name="buildwar">
    <war basedir="war" destfile="YourProject.war" webxml="war/WEB-INF/web.xml">
        <exclude name="WEB-INF/**" />
        <webinf dir="war/WEB-INF/">
            <include name="**/gwt-servlet.jar" />
            <include name="**/classes/**" />
        </webinf>
    </war>
</target>

<target name="deploy">
    <copy file="YourProject.war" todir="." />
</target>

</project>

(将 `YourProject.EntryPointClass 编辑为您的 EntryPoint-class 的路径)

(Edit `YourProject.EntryPointClass to the path to your EntryPoint-class)

您需要将 gwt-user.jargwt-dev.jar 添加到您的项目构建路径(右键单击您的项目 -> 构建路径 ->添加外部成就).

You would need to add gwt-user.jar and gwt-dev.jarto your projects build path(right click on your project -> Build Path -> Add External Achives).

如果您现在查看问题"视图,您会收到一条警告,指出这两个文件在服务器的类路径上不可用.您可以使用 QuickFix 将其复制到 WEB-INF/lib 或隐藏警告.构建文件不会在 war 文件中包含这两个文件.

If you now look at your "Problems"-view you get a warning that the two files are not available on the server's class path. You can use the QuickFix to either copy it to WEB-INF/lib or hide the warning. The build file will not include those two file in the war-file.

编译和创建文件所需要做的就是右键单击 xml 文件并选择作为 Ant Build 运行.

All you need to do to compile and create the file is to right click the xml-file and select run as Ant Build.

这篇关于从 gwt-project 创建一个 .war 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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