【问题标题】:GWT not finding custom classes?GWT 找不到自定义类?
【发布时间】:2014-01-29 04:37:09
【问题描述】:

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

我需要我的网络应用程序从服务器返回一个 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>

【问题讨论】:

    标签: java xml eclipse gwt package


    【解决方案1】:

    添加

    <source path=''/>
    

    而不是

    <source path='com.pbot'/>
    

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

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

    <source path=''/>
    

    【讨论】:

      猜你喜欢
      • 2020-05-12
      • 2017-05-10
      • 2023-01-24
      • 2014-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-28
      相关资源
      最近更新 更多