GWT:无法加载模块

时间:2009-10-30 17:13:36

标签: gwt

我想以自己的方式组织我的文件夹,但到目前为止它还没有工作。

这是我的目录结构

的src

  • com.tutorial.client
    • DictionaryModule
  • com.tutorial.module
    • Tutorial.gwt.xml

Tutorial.gwt.xml:

<module rename-to="tutorial">
  <inherits name='com.google.gwt.user.User'/>
  <inherits name='com.google.gwt.user.theme.standard.Standard'/>
  <entry-point class="com.tutorial.client.DictionaryModule"/>
</module>

DictionaryModule

package com.tutorial.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;

public class DictionaryModule implements EntryPoint {
    HorizontalPanel dictionaryPanel;
    Label wordLabel;

    public DictionaryModule(){
        dictionaryPanel = new HorizontalPanel();
        wordLabel = new Label("Word");
    }
    @Override
    public void onModuleLoad() {
        dictionaryPanel.add(wordLabel);
        RootPanel.get("dictionary").add(dictionaryPanel);
    }   
}

但是我收到了这个错误:

  

[错误] 无法找到类型   'com.tutorial.client.DictionaryModule'    [错误] 提示:以前的编译器错误   可能使这种类型不可用    [错误] 提示:检查继承   从你的模块链;它可能不是   继承所需的模块或   模块可能没有添加其来源   路径条目正确[错误]失败   加载模块'教程'

3 个答案:

答案 0 :(得分:3)

我知道你必须能够解决这个问题,但对于其他人来说,这就是我解决这个问题的方法:

我有一个使用Hibernate框架的gwt项目,并使用Maven2进行构建管理。

转到:项目&gt;属性&gt; Java构建路径&gt;订单和出口。现在确保GWT SDK 以上 Maven和JRE / JDK库。

原因是因为在多个库中有多个具有相同名称的类文件,编译器无法决定哪一个优先,所以我们必须通过指定Ordering来控制它。

答案 1 :(得分:1)

将gwt.xml放在包含 client 目录的目录中,并将以下内容添加到其中:

   <source path="module" />
   <source path="client" />

答案 2 :(得分:0)

只需更改目录结构。

 - com.tutorial.module.client

       DictionaryModule

 - com.tutorial.module

        Tutorial.gwt.xml

然后在Tutorial.gwt.xml

中添加以下内容
<module rename-to="tutorial">
  <inherits name='com.google.gwt.user.User'/>
  <inherits name='com.google.gwt.user.theme.standard.Standard'/>
  <entry-point class="com.tutorial.module.client.DictionaryModule"/>
    <source path='client'/>
</module>