GWT编译POJO
我正试图使用Ant提供的GWT的Java到Javascript编译器 我可以在不扩展任何Google类(如GWT编译POJO,gwt,compiler-construction,gwt-compiler,Gwt,Compiler Construction,Gwt Compiler,我正试图使用Ant提供的GWT的Java到Javascript编译器 我可以在不扩展任何Google类(如com.Google.GWT.core.core或类似类)的情况下使用GWT编译器吗。如果是,怎么做?我目前正在GWT2.4.0上使用下面的设置 我称之为ant任务: build.xml <target name="gwtc" description="GWT compile to JavaScript (production mode)"> <java fail
com.Google.GWT.core.core
或类似类)的情况下使用GWT编译器吗。如果是,怎么做?我目前正在GWT2.4.0上使用下面的设置
我称之为ant任务:
build.xml
<target name="gwtc" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar" />
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar" />
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="foo.Test1"/>
</java>
</target>
<module rename-to="hello">
<source path="foo.Test1"/>
<!--entry-point class="foo.Test1"/-->
</module>
foot/Test1.gwt.xml
<target name="gwtc" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar" />
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar" />
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="foo.Test1"/>
</java>
</target>
<module rename-to="hello">
<source path="foo.Test1"/>
<!--entry-point class="foo.Test1"/-->
</module>
该错误表明您需要在
gwt.xml
文件中继承'com.google.gwt.core'
,并不是说您的类应该扩展/实现它。尝试一下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE
module
PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.3.0//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/2.3.0/distro-source/core/src/gwt-module.dtd">
<module rename-to="hello">
<inherits name="com.google.gwt.core.Core" />
<source path="foo" />
</module>
还是您不希望您的模块继承它?我必须包含一个入口点,但这使我走上了正确的道路,谢谢。你知道我可以在生成的Javascript中使用Test1类的公共方法吗?据我所知,GWT编译器会检测未使用的代码/方法,并在生成的Javascript代码中删减它们。我不知道怎样才能禁用修剪。顺便说一句,如果您只需要一个用于将Java类转换为JavaScript的工具包,请查看DWR(DirectWebRemoting)。谢谢,我将尝试找到如何禁用此功能。我们已经使用了DWR,但它没有将Java转换为Javascript,而是通过Javascript存根和幕后AJAX调用从Javascript访问远程Java对象。