2011-06-30 98 views
4

我正在尝试使用Eclipse创建一个新项目,以便在maven 2系统下创建GWT应用程序。 我已创建与后续MVN命令创建GWT Maven项目

mvn archetype:generate -DarchetypeRepository=repo1.maven.org -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0 

我已经安装了后续的Eclipse插件项目: * m2eclipse的 *例如:It * GWT插件

这里我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> 

我可以使用linux shell编译和部署我的应用程序,但是我有很多问题需要在eclipse中构建和运行应用程序。

我还没有找到任何教程,解释如何创建一个一步一步GWT应用下maven内日蚀。

有人可以帮助我吗?

回答

1

这里是我的聚甲醛的设置,当我跑我的GWT应用程序与GWT相关的(我认为)部分:运行目标:

<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> 

我应该说,虽然,我现在使用的GWT Eclipse插件在Eclipse中运行我的应用程序,所以我使用这个配置已经有一段时间了。从我记得读到的,“copyWebapp”“true”是配置的关键部分之一。它还帮助我直接指定模块名称,因为gwt-maven-plugin有时会遇到问题。

9

还有一个选项:

  • 使用Eclipse中的GWT插件做一个GWT项目。现在你有一个Eclipse gwt项目。
  • 选择Project Explorer中的项目,右键单击它,然后选择Configure。然后选择Convert to Maven Project。现在你得到一个gwt-maven项目。
  • 现在添加必要的依赖关系到pom.xml
+0

遵循您的建议,我可以使用运行方式 - >(Google)Web应用程序在Eclipse中运行我的项目。但是,当我尝试运行 - >在服务器上运行时,我得到“禁止”。有人能帮我理解并修复这个错误吗? –