eclipse 创建 GWT Maven 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6540510/
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
Create a GWT Maven Project
提问by user822791
I'm trying to create a new project with Eclipse in order to create GWT application under maven 2 system. I have create the project with the follow mvn command
我正在尝试使用 Eclipse 创建一个新项目,以便在 maven 2 系统下创建 GWT 应用程序。我已经使用以下 mvn 命令创建了项目
mvn archetype:generate -DarchetypeRepository=repo1.maven.org -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0
I have installed the follow eclipse plugins: * m2eclipse * egit * gwt plugin
我已经安装了以下 eclipse 插件: * m2eclipse * egit * gwt 插件
Here my POM file:
这是我的 POM 文件:
<?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">
<!-- POM file generated with GWT webAppCreator -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.mobc3.paperquid</groupId>
<artifactId>Backoffice</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>GWT Maven Archetype</name>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.3.0</gwtVersion>
<!-- GWT needs at least java 1.5 -->
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.3.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<plugins>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.3.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
<goal>generateAsync</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->
<configuration>
<runTarget>Backoffice.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<i18nMessagesBundle>com.mobc3.paperquid.backoffice.client.Messages</i18nMessagesBundle>
</configuration>
</plugin>
<!-- Copy static web files before executing gwt:run -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
I can compile and deploy my application using the linux shell but I have many problems to build and run the application inside eclipse.
我可以使用 linux shell 编译和部署我的应用程序,但是我在 eclipse 中构建和运行应用程序时遇到了很多问题。
I haven't found any tutorial that explain how to create step by step a GWT application under maven inside eclipse.
我还没有找到任何教程来解释如何在 Eclipse 中的 Maven 下逐步创建 GWT 应用程序。
Can someone help me?
有人能帮我吗?
回答by visa
One more option:
还有一种选择:
- Make a gwt project by using the gwt plugin in Eclipse. Now you have an Eclipse gwt project.
- Select the project in
Project Explorer
, right-click it, then chooseConfigure
. Then selectConvert to Maven Project
. Now you get a gwt-maven project. - Now add necessary dependencies to
pom.xml
.
- 使用 Eclipse 中的 gwt 插件创建一个 gwt 项目。现在您有了一个 Eclipse gwt 项目。
- 在 中选择项目
Project Explorer
,右键单击它,然后选择Configure
。然后选择Convert to Maven Project
。现在你得到了一个 gwt-maven 项目。 - 现在将必要的依赖项添加到
pom.xml
.
回答by Jason482
Here is the relevant (I think) section from my pom setup when I was running my GWT app with the gwt:run goal:
当我使用 gwt:run 目标运行 GWT 应用程序时,这是我的 pom 设置中的相关(我认为)部分:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.3.0</version>
<configuration>
<runTarget>/ModuleName.html</runTarget>
<modules>
<module>${project.groupId}.package.ModuleName</module>
</modules>
<copyWebapp>true</copyWebapp>
</configuration>
<executions>
<execution>
<configuration>
<extraParam>true</extraParam>
</configuration>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
I should say, though, that I now use the GWT Eclipse Plugin to run my app within Eclipse, so it's been a while since I used this configuration. From what I remember reading, the "copyWebapp" "true" is one of the key pieces of configuration. It also helped me to specify the module name directly, because the gwt-maven-plugin sometimes had problems locating it.
不过,我应该说,我现在使用 GWT Eclipse 插件在 Eclipse 中运行我的应用程序,所以我已经有一段时间没有使用这种配置了。从我记得阅读的内容来看,“copyWebapp”“true”是配置的关键部分之一。它还帮助我直接指定模块名称,因为 gwt-maven-plugin 有时在定位它时遇到问题。