"Cannot be resolved to a type" 升级到 GWT 2.7 后。并尝试编译一个多项目模块

"Cannot be resolved to a type" after upgrading to GWT 2.7. and trying to compile a multi-project module

我一直无法让 Super-Dev-Mode 与 GWT 2.7 一起工作。和 GXT 3.1.x 经典的 Dev-Mode 启动没有问题,但 Super-Dev-Mode 和 GWT-compile 项目将无法工作。

我目前在 Java 1.7_2 Windows 上使用 Eclipse 4.4.2。 假设我们有 2 GWT/GXT 个项目(没有 Maven),使用 GWT 2.6 和 GXT 3。1.x(项目在存储库中备份)。

一个称为 A,另一个项目称为 B。项目 A 有很多包,没有入口点(仅作为 library/framework 工作),只是每个其他项目都必须扩展的抽象入口点。另一个叫B继承自A,入口点扩展了A的入口点。

在 GWT 2.6 下以经典开发模式启动项目时,项目工作正常。升级到 GWT 2.7 时。它可以在经典的开发模式下正常工作,即使在超级开发模式下,代码服务器也开始 运行,但是在编译模块时我得到一个错误,某些代码似乎不在包下 'client' 所以我将它迁移到自己的包中并将源路径添加到 A.gwt.xml.

修复此错误并再次启动超级开发模式(以及尝试 GWT 编译时)后,我收到如下错误:

 Ignored 15 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
   Finding entry point classes
      Tracing compile failure path for type 'com.example.b.client.B'
         [ERROR] Errors in 'file:/C:/Workspace/ProjectB/src/com/example/b/client/B.java'
            [ERROR] com.example.a.client.A cannot be resolved to a type
         [ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/view/ExampleLayout.java'
            [ERROR] com.example.a.view.ILayout cannot be resolved to a type
         [ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/client/service/ExampleServiceAsync.java'
            [ERROR] com.example.a.model.Examplemodel cannot be resolved to a type
         [ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/model/OtherExampleModel.java'
            [ERROR] com.example.a.hibernate.model.ComOtherExampleModel cannot be resolved to a type
         [ERROR] Errors in 'file:/C:/Workspace/ProjectB/src/com/example/b/client/service/OtherExampleServiceAsync.java'
            [ERROR] com.example.a.model.NewExampleModel cannot be resolved to a type
         ...
     (and many more)

项目 A 包含在项目 B 的构建路径中,当创建自定义 运行 配置时,将项目添加到 "user entries" 并将源文件夹添加到 "user" 条目不会工作。对于自定义 运行 配置,我使用了类似以下参数的内容:

"-src src/ -src ${workspace_loc:ProjectA} com.example.b.B"

甚至:

"-src src/ -src ${workspace_loc:ProjectA} com.example.b.B com.example.a.A"

我广泛搜索解决方案,甚至尝试重新设置工作区,再次从存储库中检出项目,组织导入,甚至将每个包添加到 A 的构建路径中。

我也尝试将其添加到 .gwt.xml 文件中,但没有成功:

<add-linker name="xsiframe"/>

如何解决 "cannot be resolved to a type" 错误? 我真的很感激各种形式的帮助来解决这个问题!谢谢!

一个可能的问题可能是您的 GXT 版本。如果您使用的是 GXT 3.1.1(最新的 GPL-release),那么您将无法使用 GWT 2.7.0。

看看版本table:

GXT versions

如您所见,Sencha GXT 3.1.1 不支持 GWT 2.7.0。第一个支持 GWT 2.7.0 的 GXT 版本是 GXT 3.1.2。