【发布时间】:2015-04-14 14:13:24
【问题描述】:
我正在尝试将我自己的包包含在 GWT 包中。如果我尝试在 GWT 应用程序中使用我自己的自定义包/类中的 Java 类,我会收到错误 “该类型没有可用的源代码。您是否忘记继承所需的模块” 而使用 Maven 构建。
我尝试了以下解决方案来解决上述问题:
- 我继承了
gwt.xml中的自定义包 - 我在 GWT maven 应用程序的
pom.xml中包含了自定义包 - 在存储库中安装了 jar
但我仍然收到上述错误。
注意:我没有在 Eclipse 中仅在命令行 maven 构建期间收到此错误。
如何使用 maven 在 GWT 包中包含我自己的包?
wmc.gwt.xml
?xml version="1.0" encoding="UTF-8"?>
<module rename-to='wmc'>
<!-- 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'/> -->
<inherits name="com.smartgwtpro.SmartGwtProNoTheme" />
<inherits name="com.smartgwtpro.tools.Tools" />
<inherits name="com.smartgwt.SmartGwtNoTheme"/>
<inherits name="com.smartclient.theme.enterprise.Enterprise"/>
<inherits name="com.smartclient.theme.enterprise.EnterpriseResources"/>
<inherits name='com.extjs.gxt.ui.GXT'/>
<inherits name='com.googlecode.gchart.GChart'/>
<inherits name='pl.balon.gwt.diagrams.Diagrams'/>
<inherits name='com.google.gwt.visualization.Visualization'/>
<inherits name='com.allen_sauer.gwt.dnd.gwt-dnd'/>
<!-- inherit the customized package for accessing the method of that bundle -->
<inherits name='com.bf.service.management'/>
<!-- Specify the app entry point class. -->
<entry-point class='com.isoft.web.viaductWebConsole.client.MonitorConsole'/>
<!-- Specify the paths for translatable code -->
<source path='wmc/client'/>
<source path='wmc'/>
<source path='web'/>
上面提到的是 gwt.xml ,你会在其中找到 <inherits name='com.bf.service.management'/> - 这是我需要在 GWT 应用程序中使用的自定义包,但是当我尝试构建 GWT 代码时,我得到了 “未能执行目标 org.codehaus.mojo:gwt-maven-plugin:2.5.1 : compile on project wmc: GWT Module com.bf.service.management not found in project sources or resources”
【问题讨论】:
-
你是在创建两个不同的maven项目还是在一个包中维护
-
嗨 mohammed 我只是维护一个包并通过 maven 构建该包。作为参考,我已经用 gwt.xml 文件更新了主要问题部分。
-
可能与您的自定义包有关?
-
不,我的感觉是 GWT 编译器无法识别我的自定义包的方法。即使我在其他一些包中使用过这种自定义包方法,它也可以正常工作。如果我在 GWT 应用程序中使用它,只会出现问题
-
也许您正在使用 GWT 无法编译的 Java 的某些功能?查看 JRE 白名单:gwtproject.org/doc/latest/RefJreEmulation.html(对不起,我无法提供更多帮助)