Java PlayN/GWT - 您是否忘记继承所需的模块?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19439419/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 17:09:48  来源:igfitidea点击:

PlayN/GWT - did you forget to inherit a required module?

javahtmlgwtplayn

提问by Epi

I'm having a weird problem when I try to compile my game in HTML. (I searched the other topics and they refer to people who are importing illegal packages, which I'm not.)

当我尝试用 HTML 编译我的游戏时遇到了一个奇怪的问题。(我搜索了其他主题,他们指的是进口非法包裹的人,我不是。)

So basically, every class called in my main one and outside of my main package throw me this error. These classes are all implemented by me and they dont import anything illegal (no reflection, no I/O, just selfmade classes and jbox2d). It seems like it's ignoring the import or something like that.

所以基本上,在我的主包中和主包之外调用的每个类都会抛出这个错误。这些类都是我自己实现的,它们没有导入任何非法的东西(没有反射,没有 I/O,只有自制的类和 jbox2d)。似乎它忽略了导入或类似的东西。

To test this, I created an empty class called Test. when it was in my main package I didn't get any error, while when I moved it outside, I got:

为了测试这一点,我创建了一个名为 Test 的空类。当它在我的主包中时,我没有收到任何错误,而当我将它移到外面时,我得到:

[INFO] [ERROR] Line 73: No source code is available for type progetto.saga.map.Test ; did you forget to inherit a required module?

[INFO] [ERROR] 第 73 行:没有适用于 progetto.saga.map.Test 类型的源代码;您是否忘记继承所需的模块?

at line 73, I just do Test test = new Test()

在第 73 行,我只是做 Test test = new Test()

this is my .gwt.xml file:

这是我的 .gwt.xml 文件:

<module rename-to='theknowledgetower'>
  <inherits name='playn.PlayN'/>
  <inherits name='TheKnowledgeTowersAssets'/>

  <source path='core'/>
  <source path='html'/>

  <public path="resources" />

  <entry-point class='progetto.saga.html.TheKnowledgeTowersHtml'/>
</module>

do you guys have any idea?

你们有什么想法吗?

Edit: this is the error I get (I get it for every custom class in my main class outside of my main package)

编辑:这是我得到的错误(我得到了我的主包之外的主类中的每个自定义类)

[INFO]       [ERROR] Line 53: No source code is available for type progetto.saga.navigable.Navigable; did you forget to inherit a required module?
[INFO]       [ERROR] Line 59: No source code is available for type progetto.saga.entity.dynamicentity.Player; did you forget to inherit a required module?
[INFO]       [ERROR] Line 110: No source code is available for type progetto.saga.navigable.button.Button; did you forget to inherit a required module?
[INFO]       [ERROR] Line 114: No source code is available for type progetto.saga.navigable.menu.HomeMenu; did you forget to inherit a required module?
[INFO]       [ERROR] Line 115: No source code is available for type progetto.saga.navigable.GameLoop; did you forget to inherit a required module?
[INFO]       [ERROR] Line 116: No source code is available for type progetto.saga.navigable.menu.CreationMenu; did you forget to inherit a required module?
[INFO]       [ERROR] Line 117: No source code is available for type progetto.saga.navigable.LoadingScreen; did you forget to inherit a required module?
[INFO]       [ERROR] Line 152: No source code is available for type progetto.saga.navigable.menu.GameMenu; did you forget to inherit a required module?
[INFO]       [ERROR] Line 153: No source code is available for type progetto.saga.map.cell.TowerFloor; did you forget to inherit a required module?
[INFO]       [ERROR] Line 154: No source code is available for type progetto.saga.map.cell.TowerWall; did you forget to inherit a required module?
[INFO]       [ERROR] Line 155: No source code is available for type progetto.saga.map.cell.TowerDecoration; did you forget to inherit a required module?
[INFO]       [ERROR] Line 156: No source code is available for type progetto.saga.entity.dynamicentity.enemy.Enemy; did you forget to inherit a required module?
[INFO]       [ERROR] Line 157: No source code is available for type progetto.saga.gui.Bar; did you forget to inherit a required module?
[INFO]       [ERROR] Line 158: No source code is available for type progetto.saga.entity.dynamicentity.equip.Equip; did you forget to inherit a required module?
[INFO]       [ERROR] Line 159: No source code is available for type progetto.saga.entity.dynamicentity.equip.Shield; did you forget to inherit a required module?
[INFO]       [ERROR] Line 160: No source code is available for type progetto.saga.entity.dynamicentity.spell.Spell; did you forget to inherit a required module?
[INFO]       [ERROR] Line 161: No source code is available for type progetto.saga.entity.staticentity.StorableDrop; did you forget to inherit a required module?
[INFO]       [ERROR] Line 162: No source code is available for type progetto.saga.entity.staticentity.Item; did you forget to inherit a required module?

采纳答案by Thomas Broyer

GWT only seesthe classes living into the sub-packages listed in <source>elements of your gwt.xmlfile.

GWT 只能看到存在于文件<source>元素中列出的子包中的类gwt.xml

So you have to add <source path="navigable"/>for each and every subpackage you want to load classes from (from the error messages, navigable, entity, map, gui, etc.)

因此,您必须为<source path="navigable"/>要从中加载类的每个子包添加(来自错误消息navigableentitymapgui、 等)

See http://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html#DevGuideModules

请参阅http://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html#DevGuideModules

回答by Qais Ammari

If no <source>element is defined , then by default GWT will look into the client path, so if you move your files under client package it should work as well.

如果没有<source>定义元素,则默认情况下 GWT 将查看客户端路径,因此如果您将文件移动到客户端包下,它应该也能正常工作。