2013-04-16 42 views
3

我有一个项目,我想使用eclipse GWT工具(开发模式和调试器)与GWT/Appengine/Maven应用程序进行交互I正在写作。我的事情有点正常,但我仍然有一些事情没有完成。如果有人能够帮助我解决这些问题,我会发布POM文件。GWT + Appengine + JPA + Eclipse + Maven:如何让它们一起工作

  • 当我做了Maven->更新项目,我失去在eclipse项目属性的AppEngine性质和必须去属性,谷歌的AppEngine并重新检查使用谷歌应用程序引擎。在POM中我可以做些什么,我不会放弃appengine的本性?我正在使用Google appengine-maven-plugin插件。这似乎是官方使用。
  • 经过一个maven构建,我必须做一个项目干净,以使jpa类得到增强,然后才能使用Run As-Web Application启动程序运行它们。 Maven构建具有在构建中工作的领域对象的测试用例 - 并且我看到在构建'maven-datanucleus-plugin:3.1.3:enhance(default)'时,这些目标得到了增强。但作为一个Web应用程序运行,它会抛出错误,告诉我这些类没有增强,除非我做一个项目清理,这会导致eclipse实现它。有没有办法避免这个额外的步骤?
  • 我无法运行JUnit View测试运行器或使用使用该视图的启动器。 JUnit视图抱怨:“org.datanucleus.exceptions.NucleusException:插件(Bundle)”org.datanucleus“已经被注册了,确保你在类路径中没有多个JAR版本的同一个插件,URL”file :/ C:/Users/bondsd/.m2/repository/org/datanucleus/datanucleus-core/3.1.3/datanucleus-core-3.1.3.jar“已经注册,并且您正在尝试注册一个相同的插件在URL“file:/ C:/Program%20Files/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.5/appengine-java-sdk-1.7.5/lib/opt/user/datanucleus/v2/datanucleus -core-3.1.3.jar。 “”。我尝试了各种各样的方法,例如删除datanucleus插件和/或依赖关系,各种配置选项以及取消选中应用程序引擎属性面板中的“使用Datnucleus JDO/JPA访问数据存储区”。有没有办法让这个工作?

以下是POM,我与公司和项目名称一起使用了POM。如果你需要发射器,我也很乐意发布它们。在此先感谢您的任何建议或帮助。我搜索了互联网,还没有找到合适的解决方案。

<modelVersion>4.0.0</modelVersion> 

<groupId>com.xxx.xxxx</groupId> 
<artifactId>shell</artifactId> 
<packaging>war</packaging> 
<version>0.1.0-proto</version> 

<name>XXXXXX</name> 
<description>A XXXXXXXX</description> 

<properties> 
    <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <!-- GWT version --> 
    <gwt.version>2.5.1</gwt.version> 
    <gwt.style>PRETTY</gwt.style> 

    <!-- GAE version --> 
    <appengine.version>1.7.6</appengine.version> 
    <appengine.sdk.version>1.7.6</appengine.sdk.version> 
    <appengine.orm.version>2.1.2</appengine.orm.version> 
    <appengine.port>8888</appengine.port> 
    <datanucleus.core.version>3.1.3</datanucleus.core.version> 
    <datanucleus.api.version>3.1.3</datanucleus.api.version> 
    <datanucleus.enhancer.version>3.1.1</datanucleus.enhancer.version> 
    <datanucleus.plugin.version>3.1.3</datanucleus.plugin.version> 

    <slf4jVersion>1.6.6</slf4jVersion> 
    <log4j.version>1.3</log4j.version> 
    <junit.version>4.11</junit.version> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>com.google.gwt.inject</groupId> 
     <artifactId>gin</artifactId> 
     <version>2.0.0</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.inject.extensions</groupId> 
     <artifactId>guice-servlet</artifactId> 
     <version>3.0</version> 
    </dependency> 

    <!-- GWT dependencies --> 
    <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> 



    <!-- GAE SDK --> 
    <dependency> 
     <groupId>com.google.appengine</groupId> 
     <artifactId>appengine-api-1.0-sdk</artifactId> 
     <version>${appengine.version}</version> 
    </dependency> 

    <!-- For the servlet filter --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 
     <version>2.5</version> 
     <scope>provided</scope> 
    </dependency> 
    <!-- <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> 
     <version>1.2</version> </dependency> --> 


    <!-- RequestFactory server --> 
    <dependency> 
     <groupId>com.trycatchsoft.gwt.requestfactory</groupId> 
     <artifactId>injected-requestfactory</artifactId> 
     <version>1.2.0-SNAPSHOT</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.web.bindery</groupId> 
     <artifactId>requestfactory-server</artifactId> 
     <version>${gwt.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.web.bindery</groupId> 
     <artifactId>requestfactory-apt</artifactId> 
     <version>${gwt.version}</version> 
    </dependency> 


    <!-- RequestFactory will use JSR 303 javax.validation --> 

    <!-- Validation API --> 
    <dependency> 
     <groupId>javax.validation</groupId> 
     <artifactId>validation-api</artifactId> 
     <version>1.0.0.GA</version> 
    </dependency> 

    <!-- Validation Implementation --> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-validator</artifactId> 
     <version>4.3.0.Final</version> 
    </dependency> 


    <!--Test Dependencies --> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>${junit.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.mockito</groupId> 
     <artifactId>mockito-all</artifactId> 
     <version>1.9.0</version> 
     <scope>test</scope> 
    </dependency> 
    <!-- GAE libraries for local testing as described here: http://code.google.com/appengine/docs/java/howto/unittesting.html --> 
    <dependency> 
     <groupId>com.google.appengine</groupId> 
     <artifactId>appengine-api-labs</artifactId> 
     <version>${appengine.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.google.appengine</groupId> 
     <artifactId>appengine-api-stubs</artifactId> 
     <version>${appengine.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.google.appengine</groupId> 
     <artifactId>appengine-testing</artifactId> 
     <version>${appengine.version}</version> 
     <scope>test</scope> 
    </dependency> 

    <!-- End of Test Dependencies --> 

    <!-- JPA 2.0 for GAE --> 
    <dependency> 
     <groupId>com.google.appengine.orm</groupId> 
     <artifactId>datanucleus-appengine</artifactId> 
     <version>${appengine.orm.version}</version> 
    </dependency> 
    <!-- Datanucleus --> 
    <!-- datanucleus-core is not needed for compilation. in fact, it cannot 
     have compile scope because the datanucleus plugin automatically adds it during 
     enhancement and complains if there are two copies. app should not depend 
     on any classes in this lib anyways. --> 
    <dependency> 
     <groupId>org.datanucleus</groupId> 
     <artifactId>datanucleus-core</artifactId> 
     <version>${datanucleus.core.version}</version> 
     <scope>runtime</scope> 
     <exclusions> 
      <exclusion> 
       <groupId>javax.transaction</groupId> 
       <artifactId>transaction-api</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

    <!-- datanucleus-jpa is needed during compilation for its @Extension annotation 
     which is used throughout entity classes --> 
    <dependency> 
     <groupId>org.datanucleus</groupId> 
     <artifactId>datanucleus-api-jpa</artifactId> 
     <version>${datanucleus.api.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.geronimo.specs</groupId> 
     <artifactId>geronimo-jpa_2.0_spec</artifactId> 
     <version>1.0</version> 
    </dependency> 

    <dependency> 
     <groupId>org.eclipse.persistence</groupId> 
     <artifactId>javax.persistence</artifactId> 
     <version>2.0.0</version> 
    </dependency> 

    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-jdk14</artifactId> 
     <version>1.7.2</version> 
    </dependency> 
    <!-- SLF4J logging libraries --> 
    <!-- <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> 
     <version>${slf4jVersion}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> <version>1.7.2</version> </dependency> 
     <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> 
     </dependency> --> 

    <!-- End SLF4J logging libraries --> 
</dependencies> 




<build> 
    <!-- Generate compiled stuff in the folder used for developing mode --> 
    <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory> 
    <resources> 
     <resource> 
      <directory>src/main/resources</directory> 
     </resource> 
    </resources> 

    <plugins> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.0</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
      </configuration> 
      <dependencies> 
       <!-- Need to run the RF Validation tool. This works on both the command-line 
        and in Eclipse, provided that m2e-apt is installed. --> 
       <dependency> 
        <groupId>com.google.web.bindery</groupId> 
        <artifactId>requestfactory-apt</artifactId> 
        <version>${gwt.version}</version> 
       </dependency> 
      </dependencies> 
     </plugin> 


     <!-- GWT Maven Plugin --> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>gwt-maven-plugin</artifactId> 
      <version>2.5.1-rc1</version> 
      <dependencies> 
       <!-- Force plugin to use same gwt version --> 
       <dependency> 
        <groupId>com.google.gwt</groupId> 
        <artifactId>gwt-user</artifactId> 
        <version>${gwt.version}</version> 
       </dependency> 
       <dependency> 
        <groupId>com.google.gwt</groupId> 
        <artifactId>gwt-dev</artifactId> 
        <version>${gwt.version}</version> 
       </dependency> 
      </dependencies> 
      <configuration> 
       <strict>true</strict> 
       <extraJvmArgs>-Xss1024K -Xmx1024M -XX:MaxPermSize=256M</extraJvmArgs> 
       <logLevel>INFO</logLevel> 
       <style>${gwt.style}</style> 
       <copyWebapp>true</copyWebapp> 
       <hostedWebapp>${webappDirectory}</hostedWebapp> 
       <runTarget>Shell.html</runTarget> 
       <webappDirectory>${webappDirectory}</webappDirectory> 
       <module>com.ihg.dashboard.Shell</module> 
       <server>com.google.appengine.tools.development.gwt.AppEngineLauncher</server> 
       <i18nMessagesBundle>com.ihg.dashboard.client.Messages</i18nMessagesBundle> 
       <appEngineVersion>${appengine.version}</appEngineVersion> 
       <!-- Should GWT create the Story of Your Compile Report --> 
       <compileReport>false</compileReport> 
      </configuration>     
      <executions> 
       <execution> 
        <goals> 
         <goal>compile</goal> 
         <goal>test</goal> 
         <goal>i18n</goal> 
        </goals> 
       </execution> 
      </executions> 

     </plugin> 

     <plugin> 
      <groupId>com.google.appengine</groupId> 
      <artifactId>appengine-maven-plugin</artifactId> 
      <version>${appengine.version}</version> 
      <configuration> 
       <jvmFlags> 
        <jvmFlag>-Ddatastore.backing_store=${project.basedir}\local_db.bin</jvmFlag> 
       </jvmFlags> 
       <enhancerApi>JPA</enhancerApi> 
      </configuration> 
     </plugin> 


     <!-- This plug-in "enhances" your domain model objects (i.e. makes them 
      persistent for datanucleus) --> 
      <!-- Might not need this, appengine is supposed to do this appengine:enhance --> 
     <plugin> 
      <groupId>org.datanucleus</groupId> 
      <artifactId>maven-datanucleus-plugin</artifactId> 
      <version>${datanucleus.plugin.version}</version> 
      <configuration> 
       <mappingIncludes>**/domain/*.class</mappingIncludes> 
       <metadataIncludes>**/domain/*.class</metadataIncludes> 
       <verbose>false</verbose> 
       <enhancerName>ASM</enhancerName> 
       <api>JPA</api> 
      </configuration> 
      <executions> 
       <execution> 
        <phase>process-classes</phase> 
        <goals> 
         <goal>enhance</goal> 
        </goals> 
       </execution> 
      </executions> 
      <dependencies> 
       <dependency> 
        <!-- enhancement requires the gwt-user jar because many of the entity 
         classes implement IsSerializable and the enhancer needs it on the classpath 
         to function. because the gwt-user library has a scope of provided, it is 
         only available on the compilation and test classpath, and is not transitive 
         to the enhancement classpath. --> 
        <groupId>com.google.gwt</groupId> 
        <artifactId>gwt-user</artifactId> 
        <version>${gwt.version}</version> 
       </dependency> 
       <dependency> 
        <!-- force maven-datanucleus-plugin to use the same version of datanucleus-core --> 
        <groupId>org.datanucleus</groupId> 
        <artifactId>datanucleus-core</artifactId> 
        <version>${datanucleus.core.version}</version> 
       </dependency> 
      </dependencies> 
     </plugin> 




     <!-- Copy static web files before executing gwt:run --> 
     <!-- May not need this now --> 
     <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> 
       <webXml>${webappDirectory}/WEB-INF/web.xml</webXml> 
       <webappDirectory>${webappDirectory}</webappDirectory> 
      </configuration> 
     </plugin> 

    </plugins> 



    <pluginManagement> 
     <plugins> 
      <!--This plugin's configuration is used to store Eclipse m2e settings 
       only. It has no influence on the Maven build itself. --> 
      <plugin> 
       <groupId>org.eclipse.m2e</groupId> 
       <artifactId>lifecycle-mapping</artifactId> 
       <version>1.0.0</version> 
       <configuration> 
        <lifecycleMappingMetadata> 
         <pluginExecutions> 
          <pluginExecution> 
           <pluginExecutionFilter> 
            <groupId>org.codehaus.mojo</groupId> 
            <artifactId> 
             gwt-maven-plugin 
            </artifactId> 
            <versionRange> 
             [2.5.1-rc1,) 
            </versionRange> 
            <goals> 
             <goal>i18n</goal> 
            </goals> 
           </pluginExecutionFilter> 
           <action> 
            <ignore></ignore> 
           </action> 
          </pluginExecution> 
          <pluginExecution> 
           <pluginExecutionFilter> 
            <groupId> 
             org.datanucleus 
            </groupId> 
            <artifactId> 
             maven-datanucleus-plugin 
            </artifactId> 
            <versionRange> 
             ${datanucleusVersion} 
            </versionRange> 
            <goals> 
             <goal>enhance</goal> 
            </goals> 
           </pluginExecutionFilter> 
           <action> 
            <execute /> 
           </action> 
          </pluginExecution> 
         </pluginExecutions> 
        </lifecycleMappingMetadata> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
</build> 

=======================================

On编辑:下面是第3点的解决方案。禁用项目属性 - Google - App Engine页面中的JPA/JDO。转到构建路径并删除所有作为顶级库列出的datanucleus库(通过在项目属性中启用appengine来放置这些库)。确保Maven依赖关系位于Order选项卡的列表底部。

On编辑2:我找到了一种方法来保持GAE项目的性质,当我做Maven-> Update Project时。我已将此添加到POM(即使我使用Eclipse构建安装M2E)

  <plugin> 
      <artifactId>maven-eclipse-plugin</artifactId> 
      <version>2.7</version> 
      <configuration> 
       <downloadSources>true</downloadSources> 
       <downloadJavadocs>false</downloadJavadocs> 
       <wtpversion>2.0</wtpversion> 
       <additionalBuildcommands> 
        <buildCommand> 
         <name>com.google.gwt.eclipse.core.gwtProjectValidator</name> 
        </buildCommand> 
       </additionalBuildcommands> 
       <additionalProjectnatures> 
        <projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature> 
        <projectnature>com.google.appengine.eclipse.core.gaeNature</projectnature> 
       </additionalProjectnatures> 
      </configuration> 
     </plugin> 

这解决了点句1.所以现在我有个1和3解决(种)。我仍然需要一种方法来解决第二点,尽管如果我记得这样做,解决方法很简单。我记得这样做后,我更担心那些获得代码的人。

我也在寻找一种方式,以不使用Eclipse启动的。我知道这可以通过添加各种配置文件和配置来完成。我只需要找到正确的配置来做到这一点。通过这个,我的意思是一个配置文件,它将以开发模式(或超级开发模式)运行gwt代码,以及一个将以开发模式运行带有gwt代码的调试器的配置文件。


上编辑3:我解决了子弹点2.这是因为关闭项目 - >自动构建简单。我不确定首先发生了什么。

这就是所有解决的3个要点。在这一点上,我可能应该为这个问题创建一个答案,并将它标记为对那些对此感兴趣并且没有读到的人。我会在一两天内做到这一点(当我有时间撰写一个很好的答案时)。

+0

你有没有通过GWT样品POM文件@ https://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/mobilewebapp/pom.xml和https不见了。 google.com/p/google-web-toolkit/source/browse/trunk/samples/dynatablerf/pom.xml和https://code.google.com/p/google-web-toolkit/source/browse/trunk/样品/验证/ pom.xml – SSR

+0

我已经看过那些。第一个使用Objectify(而不是JPA)并使用不同的appengine插件:net.kindleit maven-gae-plugin。第二个和第三个没有任何帮助,因为他们似乎没有使用应用程序引擎。谢谢。 – Deanna

回答

1

它看起来像你的maven设置是好的,但让我做一些可能有所帮助的观察。

1)我们只是执行同样的事情Maven的DataNucleus将-插件我会删除从AppEngine上,Maven的插件enhancerApi。因此,不要运行appengine:增强目标以及datanucleus插件的目标。

2)DataNucleus将插件的设置既提升域类,这听起来我的权利,但只是验证这一点,我猜。

3)我不再是最好的日食了,但我很好奇你使用的maven插件,m2eclipse插件是由sonatype开发的,在我看来是最准确的插件。

4)编译战争插件的执行似乎是我错了,因为这应该默认为package阶段,无论如何,确保其他阶段已正确执行事前。

5)您可能需要获得设立几个执行指令的插件,或者依赖于默认,如果它们存在。 maven的生命周期可能有点棘手,我建议您阅读http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html,并确保eclipse在启动应用程序之前运行正确的阶段。 //代码:

+0

谢谢。我从appengine-maven插件中删除了enhancerApi。你的第二点是正确的。我只想增强域类。我正在使用eclipse J2ee Juno附带的m2eclipse - 这是sonatype插件。我将删除战争插件 - 这是我在玩清单文件时发生的。我会再次阅读生命周期阶段,但maven构建部分似乎正在工作。这只是越来越与它整合,我遇到了问题。再次感谢。 – Deanna

+0

我想你可能需要定义war插件,因为你可以像这样对archiveClasses说:https://github.com/mattstep/appengine-guestbook-java/blob/master/pom.xml#L82。我的直觉是,m2eclipse插件正在对阶段和生命周期进行一些假设,当你得到这个结果时,eclipse很可能会开始更加顺畅地运行Maven。 – MattStep

+0

谢谢。我从未深入研究过m2eclipse生命周期管理。我看到有一个可以覆盖的xml文件。这将需要一些研究。我会给它一个镜头。 – Deanna

相关问题