2

我使用 GWTTestCase 编写简单的测试,这里是:

public class SampleTest extends GWTTestCase {

    @Override
    public String getModuleName() {
        return "path.to.my.one.and.only.Module";
    }

    public void testSome() {
        assertNotNull(null);
    }
}

但是当我运行mvn test时,测试失败并出现下一个错误:

[ERROR] Unable to find type 'java.lang.Object'
   [ERROR] Hint: Check that your module inherits 'com.google.gwt.core.Core' either directly or indirectly (most often by inheriting module 'com.google.gwt.user.User')
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.648 sec <<< FAILURE!

我的模块中有“com.google.gwt.user.User”。

4

2 回答 2

0

该错误表明您需要com.google.gwt.core.Coregwt.xml文件中继承,并不是说您的类应该扩展/实现它。

因为你没有提供gwt.xml。我举个例子。

在您的 gwt.xml 中尝试一下:

<?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" /> <!-- Your package name -->
</module>
于 2012-05-23T08:21:22.530 回答
0

我设法通过修复我的 JRE 定义来解决此问题,为此请转到Window > Preferences > Java > Installed JREs > Add your JRE's correct path。你去吧!

于 2018-03-09T10:20:51.030 回答