我们使用 seam+richfaces+gwt,效果很好。尽管我们使用 maven 构建一切,但我想您也可以使用 ant。总体思路是在 GWT 开发模式下启动整个 Web 应用程序。您不必编译所有内容(在 GWT 编译器的情况下需要很长时间)。开发模式将按需编译请求的资源。通过以这种方式运行 GWT 应用程序,您还可以调试客户端代码。
也可以调用 GWT 方法来响应接缝动作。
更新:
我可以详细说明一下我们的解决方案:
马文
您的项目应配置为packaging: war
. 有一些关于使用 maven 设置接缝的官方说明(也是richfaces):
http://docs.jboss.org/seam/2.2.1.CR2/reference/en-US/html/dependencies.html#d0e34791
http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/SettingsForDifferentEnvironments.html
对于 GWT,将以下部分添加到您的pom.xml
:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.1.0</version>
<scope>provided</scope> <!-- prevents from including this in war -->
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>2.1.0</version>
<scope>provided</scope> <!-- prevents from including this in war -->
</dependency>
<dependency>
<groupId>pl.ncdc.gwt</groupId>
<artifactId>gwt-servlet-war</artifactId>
<version>2.1.0</version>
<type>war</type> <!-- adds gwt-servlet.jar to your war, but not to your classpath -->
</dependency>
<!-- build section -->
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/client/**/*.java</include>
<include>**/client/**/*.properties</include>
<include>**/shared/**/*.java</include>
<include>**/shared/**/*.properties</include>
<include>**/*.gwt.xml</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java</directory>
<includes>
<include>**/client/**/*.java</include>
<include>**/client/**/*.properties</include>
<include>**/shared/**/*.java</include>
<include>**/shared/**/*.properties</include>
<include>**/*.gwt.xml</include>
</includes>
</testResource>
</testResources>
<plugins>
<plugin> <!-- dirty hack for GWT issue #3439 - it is not really fixed -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>remove-javax</id>
<phase>compile</phase>
<configuration>
<tasks>
<delete dir="${project.build.directory}/classes/javax" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.3.2.google</version>
<configuration>
<extraJvmArgs>-Xmx512M</extraJvmArgs>
<gwtVersion>${gwt.version}</gwtVersion>
<modules>
<module>com.company.gwt.project.module.Module</module>
</modules>
<soyc>false</soyc>
<draftCompile>${gwt.draft.compile}</draftCompile> <!-- you can control this with profiles -->
<localWorkers>2</localWorkers><!-- in theory should speed things up on our quad CPU hudson -->
<style>${gwt.style}</style> <!-- you can control this with profiles -->
</configuration>
<executions>
<execution>
<id>compile</id>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>gwt-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>**/*GwtTestSuite.java</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<archiveClasses>true</archiveClasses>
<warSourceDirectory>src/main/webapp-empty</warSourceDirectory> <!-- just empty dir for workaround -->
<webResources>
<resource>
<directory>src/main/webapp</directory>
<excludes>
<exclude>app.*</exclude> <!-- name of you gwt module(s) - rename-to in gwt.xml -->
<exclude>WEB-INF/web.xml</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/webapp</directory>
<includes>
<include>WEB-INF/web.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
此配置应该与 - seam 和 gwt 编译产生战争。如果您想在开发模式下使用此类项目,请将其放入pom.xml
:
<dependency>
<groupId>com.xemantic.tadedon</groupId>
<artifactId>tadedon-gwt-dev</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
并添加-server com.xemantic.tadedon.gwt.dev.JettyLauncher
到您的谷歌网络应用程序启动器。这是 maven 友好的码头发射器,在某些情况下可能是必要的。
我希望它会帮助你。您对 gwt 和richfacaes 应用程序之间的通信感兴趣吗?