简体   繁体   English

由gwt-maven-plugin生成的导入项目

[英]Import project generated by gwt-maven-plugin

i followed the instruction of gwt-maven-plugin , generated then imported the project below, 我按照gwt-maven-plugin的指令生成,然后将其导入下面的项目,

1) Generate the project 1)生成项目

$ mvn archetype:generate \
   -DarchetypeGroupId=org.codehaus.mojo \
   -DarchetypeArtifactId=gwt-maven-plugin \
   -DarchetypeVersion=2.5.0

...

Define value for property 'groupId': : org.codehaus.mojo
Define value for property 'artifactId': : gwt-maven-plugin-sample
Define value for property 'version':  1.0-SNAPSHOT: : 
Define value for property 'package':  org.codehaus.mojo: : 
Define value for property 'module': : Sample 

...

2) Check the generated POM 2)检查生成的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>org.codehaus.mojo</groupId>
  <artifactId>gwt-maven-plugin-sample</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>GWT Maven Archetype</name>

  <properties>
    <!-- Convenience property to set the GWT version -->
    <gwtVersion>2.5.0</gwtVersion>
    <!-- GWT needs at least java 1.5 -->
    <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-servlet</artifactId>
      <version>${gwtVersion}</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <version>${gwtVersion}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.7</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.0.0.GA</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.0.0.GA</version>
      <classifier>sources</classifier>
      <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.5.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>Sample.html</runTarget>
          <hostedWebapp>${webappDirectory}</hostedWebapp>
          <i18nMessagesBundle>org.codehaus.mojo.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>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>

3) Check the generated project 3)检查生成的项目

gwt-maven-plugin-sample/
├── .classpath
├── pom.xml
├── .project
├── SampleTest-dev.launch
├── SampleTest-prod.launch
├── .settings
│   ├── com.google.appengine.eclipse.core.prefs
│   ├── com.google.gdt.eclipse.core.prefs
│   ├── com.google.gwt.eclipse.core.prefs
│   ├── .jsdtscope
│   ├── org.eclipse.jdt.core.prefs
│   ├── org.eclipse.wst.common.component
│   ├── org.eclipse.wst.common.project.facet.core.xml
│   ├── org.eclipse.wst.jsdt.ui.superType.container
│   └── org.maven.ide.eclipse.prefs
├── src
│   ├── main
│   │   ├── java
│   │   │   └── org
│   │   │       └── codehaus
│   │   │           └── mojo
│   │   │               ├── client
│   │   │               │   ├── GreetingService.java
│   │   │               │   └── Sample.java
│   │   │               ├── server
│   │   │               │   └── GreetingServiceImpl.java
│   │   │               └── shared
│   │   │                   └── FieldVerifier.java
│   │   ├── resources
│   │   │   └── org
│   │   │       └── codehaus
│   │   │           └── mojo
│   │   │               ├── client
│   │   │               │   ├── Messages_fr.properties
│   │   │               │   └── Messages.properties
│   │   │               └── Sample.gwt.xml
│   │   └── webapp
│   │       ├── Sample.css
│   │       ├── Sample.html
│   │       └── WEB-INF
│   │           └── web.xml
│   └── test
│       ├── java
│       │   └── org
│       │       └── codehaus
│       │           └── mojo
│       │               └── client
│       │                   └── GwtTestSample.java
│       └── resources
│           └── org
│               └── codehaus
│                   └── mojo
│                       └── SampleJUnit.gwt.xml
└── target
    └── generated-sources
        └── gwt
            └── org
                └── codehaus
                    └── mojo

33 directories, 26 files

4) On Eclipse, choose "Import Existing Project to Workspace" 4)在Eclipse上,选择“将现有项目导入到工作区”

进口日食项目

5) According to the instruction of gwt-maven-plugin , the imported project should have resulted in the project structure similar to below, 5)根据gwt-maven-plugin的说明 ,导入的项目应具有与以下类似的项目结构,

预期的日食项目

In the end by our comparing 4) to 5), the problem in sight seems that no maven dependencies were added by the import at all, in other words, the generated project was not validated as a maven project. 最后,通过将4)与5)进行比较,可见的问题似乎根本没有通过导入添加任何Maven依赖项,换句话说,生成的项目没有被验证为Maven项目。 So, what's wrong with the steps above and the configuration below? 那么,上面的步骤和下面的配置有什么问题?

gwt-maven-plugin 2.5.0
m2e 1.2.0.20120903-1050
eclipse 3.7.2
maven 3.0.4

@EDIT @编辑

Ran "mvn gwt:run" successfully, but failed to launch DevMode by GWT Eclipse Plugin , 成功运行“ mvn gwt:run”,但无法通过GWT Eclipse Plugin启动DevMode

gwt devmode错误

@EDIT 2 @编辑2

Referring to the link from @Sachin Shekhar R , i've looked into the official GWT Wiki: working with maven , followed the instruction and tested DynaTable RequestFactory sample . 参考@Sachin Shekhar R的链接,我研究了官方的GWT Wiki:使用maven ,按照说明进行操作并测试了DynaTable RequestFactory示例 Great, it does work! 很好,确实有效!

Unfortunately, the Wiki echoes that gwt-maven-plugin does have issues with the archetype in use. 不幸的是,Wiki回应了gwt-maven-plugin确实存在使用archetype方面的问题。

gwt-maven-plugin 2.5.0 works best with GWT 2.5.0. gwt-maven-plugin 2.5.0与GWT 2.5.0一起使用效果最佳。 The statement Ran "mvn gwt:run" successfully, but failed to launch DevMode by GWT Eclipse Plugin is a bit confusing. 语句Ran“ mvn gwt:run”成功,但未能通过GWT Eclipse Plugin启动DevMode有点令人困惑。

I also noticed that in your case - 我还注意到您的情况-

1) The generated pom file in indicates 2.5.0 and eclipse screenshot indicates 2.0.4. 1)生成的pom文件表示2.5.0,而eclipse屏幕截图表示2.0.4。 This might because your GPE is pointing to GWT 2.0.4 and overriding the pom files directive. 这可能是因为您的GPE指向GWT 2.0.4并覆盖了pom files指令。

2) If you are using maven gwt:run then GWT Eclipse Plugin is irrelevant. 2)如果您使用的是maven gwt:run,那么GWT Eclipse插件是无关紧要的。 The dev mode gets launched either by 开发者模式either通过以下方式启动

  • a) mvn gwt:run a) mvn gwt:run
  • b) by GWT Eclipse Plugin when you right click on project and select Debug As -> Web Application b)当您右键单击项目并选择Debug As > Web Application时,通过GWT Eclipse Plugin

3) Maven dependencies are being shown in the screenshot you have shared. 3)Maven依赖项显示在您共享的屏幕快照中。 Can you expand it and verify which jars are being picked up. 您可以扩展它并验证要拾取的罐子吗?

Edit - You can try some additional troubleshooting tips from with http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven Edit -您可以尝试使用http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven中的一些其他疑难解答提示

My guess would be the configuration @ Project properties, Google > Web Application, the "This project has a WAR directory" 我的猜测是配置@ Project properties, Google > Web Application, the "This project has a WAR directory"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM