我创建了一个具有以下结构的GWT Maven Multi Module项目。
核心模块[包含活动,演示者,共享资源] 带入口点的core.gwt.xml
core.gwt.xml
<inherits name='com.google.gwt.user.User' />
<!-- We need the JUnit module in the main module, -->
<!-- otherwise eclipse complains (Google plugin bug?) -->
<!--<inherits name='com.google.gwt.junit.JUnit' /> -->
<!-- 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.standard.Standard' /> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- <stylesheet src="styles-global.css"/> -->
<!--GWT-QUERY -->
<!-- <inherits name='com.google.gwt.query.Query'/> -->
<!--SuperDev Mode -->
<!-- add-linker name="xsiframe"/> <set-configuration-property name="devModeRedirectEnabled"
value="true"/-->
<set-property name="user.agent" value="gecko1_8,safari" />
<!-- Other module inherits -->
<!-- We need the MVP stuff (Activity and Place -->
<!-- I am also using DepInj with Gin (Inject) -->
<!-- and Resource for client bundle and stuff (not used yet) -->
<inherits name="com.google.gwt.activity.Activity" />
<inherits name="com.google.gwt.place.Place" />
<inherits name="com.google.gwt.inject.Inject" />
<inherits name="com.google.gwt.resources.Resources" />
<inherits name="com.google.gwt.user.Debug" />
<inherits name="org.fusesource.restygwt.RestyGWT"/>
<!-- gwtbootstrap3 -->
<inherits name="com.template.resources.CustomBootstrap"/>
<!-- Specify the app entry point class. -->
<entry-point class='com.template.core.client.template' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
<!-- Form Factors -->
<inherits name="com.template.core.FormFactor" />
<!-- For JSON Ajax call -->
<inherits name="com.google.gwt.http.HTTP" />
<!-- For Logging Framework src: https://developers.google.com/web-toolkit/doc/latest/DevGuideLogging -->
<inherits name="com.google.gwt.logging.Logging" />
<set-property name="gwt.logging.enabled" value="FALSE" />
<define-configuration-property name="gin.ginjector"
is-multi-valued="false" />
<set-configuration-property name='gin.ginjector'
value='com.template.core.client.ioc.ClientGinjector' />
<!-- gwt dnd -->
<inherits name='com.allen_sauer.gwt.dnd.gwt-dnd'/>
桌面模块[包含具有桌面特定视图的桌面模块] 带入口点的desktop.gwt.xml
desktop.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<inherits name='com.template.core.template' />
<entry-point class='com.template.desktop.client.desktoptemplate' />
<source path='client' />
平板电脑模块[包含平板电脑特定视图的平板电脑模块] 带入口点的tablet.gwt.xml
移动模块[包含具有移动特定视图的移动模块] 带入口点的mobile.gwt.xml
桌面,平板电脑和移动设备取决于核心模块。我还继承了设备模块中的核心模块,并提到了核心在设备模块中的依赖性
我能够在eclipse中使用google gwt插件单独运行这些模块。但是,当我在根项目上执行maven安装时,核心模块的入口点无法找到并抛出异常。
[错误]无法找到类型&#39; com.template.core.client.template&#39; [INFO] [ERROR]提示:检查类型名称&#39; com.template.core.client.template&#39;真的是你的意思 [INFO] [ERROR]提示:检查您的类路径是否包含所有必需的源根 [INFO] [错误]&#39;文件中的错误:/home/software/mmt/template_ui/template_ui_desktop/src/main/java/com/template/desktop/client/desktoptemplate.java' [INFO] [ERROR]第20行:没有源代码可用于类型com.template.core.client.ioc.ClientGinjector;你忘了继承一个必需的模块吗? [INFO] [ERROR]第21行:没有源代码可用于类型com.template.core.client.application.main.ServletURL;你忘了继承一个必需的模块吗? [INFO] [ERROR]无法找到类型&#39; com.template.desktop.client.desktoptemplate&#39; [INFO] [ERROR]提示:以前的编译器错误可能导致此类型不可用 [INFO] [ERROR]提示:检查模块的继承链;它可能没有继承所需的模块,或者模块可能没有正确添加其源路径条目
[INFO]模板用户界面......................................... ...........................成功[1.374 s] [INFO]核心模块............................................. ........................................成功[46.110 s] [INFO]桌面模块............................................. .....................................失败[23.713 s] [INFO]平板电脑模块............................................. ....................... ........................... ....... SKIPPED [INFO]移动模块............................................. .................................................. ..... SKIPPED
解决方案
gwt库应该同时包含.java和.class文件。所以我们需要打包这两个文件(你也可以使用.css,.png,.html e.t.c.,文件)。您可以使用以下pom.xml配置来包含它们。
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.ui.xml</include>
<include>**/*.java</include>
<include>**/*.gwt.xml</include>
<include>**/*.html</include>
<include>**/*.js</include>
<include>**/*.css</include>
<include>**/*.gif</include>
<include>**/*.jpg</include>
<include>**/*.png</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.ui.xml</include>
<include>**/*.java</include>
<include>**/*.gwt.xml</include>
<include>**/*.html</include>
<include>**/*.js</include>
<include>**/*.css</include>
<include>**/*.gif</include>
<include>**/*.jpg</include>
<include>**/*.png</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
我在我的核心pom.xml中使用了这个配置
答案 0 :(得分:0)
gwt库应该同时包含.java和.class文件。所以我们需要打包这两个文件(你也可以使用.css,.png,.html e.t.c.,文件)。您可以使用以下pom.xml配置来包含它们。
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.ui.xml</include>
<include>**/*.java</include>
<include>**/*.gwt.xml</include>
<include>**/*.html</include>
<include>**/*.js</include>
<include>**/*.css</include>
<include>**/*.gif</include>
<include>**/*.jpg</include>
<include>**/*.png</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.ui.xml</include>
<include>**/*.java</include>
<include>**/*.gwt.xml</include>
<include>**/*.html</include>
<include>**/*.js</include>
<include>**/*.css</include>
<include>**/*.gif</include>
<include>**/*.jpg</include>
<include>**/*.png</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
我在我的核心的pom.xml中使用了这个配置