GWT没有找到自定义类?

时间:2014-01-10 09:22:40

标签: java xml eclipse gwt package

我一直在互联网上,似乎无法得到一个直接的答案,只是想澄清一些事情。

我需要我的网络应用程序从服务器返回一个ArrayList。 Por是一个实现Serializable的自定义类,遵循我能够找到的关于GWT可序列化的所有规则。

我的gwt.xml文件(在com.pbot包中)有:

<source path='com.pbot'/>

我的所有自定义类(包括Por)都在同一个com.pbot包中。但我仍然得到“没有源代码可用于类型com.pbot.Por;你忘了继承一个必需的模块吗?”信息。我是否需要使用com.pbot作为源创建第二个gwt.xml并导入它?如果是这样,我该怎么做,我该把它放在哪里?如果没有,我错过了什么?

下面的整个gwt.xml代码:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  When updating your version of GWT, you should also update this DTD reference,
  so that your app can take advantage of the latest GWT module capabilities.
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN"
  "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='pbot'>
  <!-- Inherit the core Web Toolkit stuff.                        -->
  <inherits name='com.google.gwt.user.User'/>

  <!-- Inherit the default GWT style sheet.  You can change       -->
  <!-- the theme of your GWT application by uncommenting          -->
  <!-- any one of the following lines.                            -->
  <inherits name='com.google.gwt.user.theme.clean.Clean'/>
  <!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

  <!-- Other module inherits                                      -->

  <!-- Specify the app entry point class.                         -->
<entry-point class='com.pbot.client.Pbot'/>
  <!-- Specify the paths for translatable code                    -->
  <source path='client'/>
  <source path='shared'/>
  <source path='com.pbot'/>

</module>

1 个答案:

答案 0 :(得分:1)

添加

<source path=''/>

而不是

<source path='com.pbot'/>

但我认为你应该把你的自定义类放到正确的包中,所以如果是Por进入共享包(因为你在客户端和服务器端都使用Por)。但是,我不知道情况(如果你能这样做),所以这只是一个建议。

这背后的原因是,你提供整个包com.pkg被翻译成JavaScript,不久你会遇到这种态度的麻烦。最好的事情是 - 如果可能的话,将自定义类放入客户端或共享包中,然后删除

<source path=''/>