Maven + GAE一步一步

时间:2011-10-26 12:29:04

标签: java eclipse google-app-engine maven

我正在寻找一个关于如何“mavenize”由Google Eclipse插件创建的Google AppEngine项目的基础教程。

如果太难了,如何创建Maven项目,添加GAE支持然后将其导入Eclipse并从那里使用GooglePlugin?

P.S。如果我也想要SpringMVC怎么办?

1 个答案:

答案 0 :(得分:4)

我不确定如何从eclipse创建maven项目,但从头开始创建它非常容易。对于gae,您可以使用net.kindleit:maven-gae-plugin查看http://www.kindleit.net/maven_gae_plugin/index.html,它可以为您生成pom.xml。或者只是将其用作

<plugin>
  <groupId>net.kindleit</groupId>
  <artifactId>maven-gae-plugin</artifactId>
  <version>0.8.4</version>
  <configuration>
      <port>8080</port>
      <address>127.0.0.1</address>
  </configuration>
  <executions>
      <execution>
        <id>start-gae</id>
        <goals>
          <goal>stop</goal>
          <goal>unpack</goal>
          <goal>start</goal>
        </goals>
      </execution>
      <execution>
        <id>stop-gae</id>
        <goals>
          <goal>stop</goal>
        </goals>
      </execution>
    </executions>
</plugin> 

但不要忘记添加GAE依赖项:

    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-1.0-sdk</artifactId>
        <version>${gae.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-labs</artifactId>
        <version>${gae.version}</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-stubs</artifactId>
        <version>${gae.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-testing</artifactId>
        <version>${gae.version}</version>
        <scope>test</scope>
    </dependency>

和存储库:

<pluginRepositories>
    <pluginRepository>
        <id>maven-gae-plugin-repo</id>
        <name>maven-gae-plugin repository</name>
        <url>http://maven-gae-plugin.googlecode.com/svn/repository</url>
    </pluginRepository>
</pluginRepositories>

<repositories>
    <repository>
        <id>maven-gae-plugin-repo</id>
        <name>maven-gae-plugin repository</name>
        <url>http://maven-gae-plugin.googlecode.com/svn/repository</url>
    </repository>
</repositories>

然后您可以使用mvn eclipse:eclipse

生成eclipse配置

开发服务器可以mvn gae:run启动,部署mvn gae:deploy

要使用Spring,请将依赖项添加到组spring-webmvc下的工件spring-corespring-contextorg.springframework