编辑:我已使用 OP 提供的其他步骤更新了我的答案。详细信息请注明 OP。
我刚刚破坏了我的Eclipse设置,试图安装最新版本的Google Plugin for Eclipse(用于GWT 2.0),所以我无法确认所有内容,但是,让我们假设满足以下先决条件:
您是否尝试过:
从 Eclipse 创建一个新项目(“新建>其他...”,然后选择“Maven 项目”并选择 gwt-maven-plugin 原型)。
编辑生成的 ,将属性更新为(已在中央存储库中发布),添加 Codehaus Snapshot 存储库并将版本设置为 1.2-SNAPSHOT
(版本 1.2 未在 central 中发布,这应该很快就会发生)(也已在 central 中发布)。pom.xml
gwt.version
2.0.0
gwt-maven-plugin
1.2
将 添加到 gwt-maven-plugin 配置中,如使用 Google Eclipse 插件中所述。<runTarget>
配置 maven-war-plugin,如上一步中提到的页面所述。
通过设置“使用 Google Web 工具包”复选框,从项目首选项中手动启用项目 GWT此步骤是不必要的,因为您将使用 Maven 运行配置构建/运行,而不是 Eclipse 的 GWT 插件。
这就是我的实际样子:pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!--
GWT-Maven archetype generated POM
-->
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.demo</groupId>
<artifactId>my-gwtapp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>gwt-maven-archetype-project</name>
<properties>
<!-- convenience to define GWT version in one place -->
<gwt.version>2.0.0</gwt.version>
<!-- tell the compiler we can use 1.5 -->
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
</properties>
<dependencies>
<!-- GWT dependencies (from central repo) -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
<!-- test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<outputDirectory>war/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>generateAsync</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>com.mycompany.demo.gwt.Application/Application.html</runTarget>
</configuration>
</plugin>
<!--
If you want to use the target/web.xml file mergewebxml produces,
tell the war plugin to use it.
Also, exclude what you want from the final artifact here.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>target/web.xml</webXml>
<warSourceExcludes>.gwt-tmp/**</warSourceExcludes>
</configuration>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<warSourceDirectory>war</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
运行目标(使用 m2eclipse Maven2 >构建...)来设置环境并为 GWT 模块创建启动配置。gwt:eclipse
运行以编译并在 GWT 托管模式下运行 GWT 模块。gwt:compile gwt:run