Apache Maven是一个软件项目管理的综合工具(management and comprehension tool)。可以将WAR文件部署到App Engine中。为了加快部署的速度,App Engine团队提供了插件和Maven原型这两个东西(plugin and Maven Archetypes)。

注意:使用Maven时,你不需要从Google App Engine SDK下载java库。Maven会为你做这个事情。你也可以使用Maven在本地测试你的应用,以及将应用部署到生产环境的App Engine。

先决条件

1.安装Java 7。

2.设置环境变量JAVA_HOME 。

3.安装Maven

App Engine Managed VMs Maven projects 的处理不同

Maven projects 和 Eclipse

Maven项目和Eclipse项目有不同的结构(layout)。要在Eclipse中使用Maven项目,需要使用Eclipse for Java Enterprise Edition,它支持Maven。并且需要使用下面方法中的一个:

● 将Maven项目导入到Eclipse

● 将Maven项目作为一个WTP(Web Tools Platform)项目导入到Eclipse

● 设置两个Debug配置。一个为devserver中的Maven项目(mvn:appengine:devserver),一个为远程Java应用,你将使用它连接devserver jvm和Eclipse debug client。

具体怎么做,可以参考这个StackOverflow 问题的回答How do I make Eclipse and mvn appengine:devserver talk to each other?

你需要知道的Maven术语

在项目的创建过程中,Maven提示你需要提供这个项目的groudId,artifactId,version,以及package。这些在Maven中代表什么呢?

术语 含义
groupId Maven中的命名空间来跟踪你的artifacts。当别人在他们的项目中使用你的项目时,这个就是他们指定的依赖属性。
artifactId 在Maven中,你的项目的名字。当你的项目的用户在他们自己的Maven项目中依赖你时,也可以指定为你的项目的用户。
version 你希望你的项目生成时使用的原始的Maven版本。让其以-SNAPSHOT结尾是一个不错的想法。因为这样做可以对开发中的版本Maven release Plugin的支持。
package 这一代创建的Java包

Maven App Engine archetypes

Maven archetypes允许用户使用覆盖了公共场景的模板来创建Maven项目。App Engine利用了这个Maven特性,在Maven中心提供了一些有用的 App Engine archetypes 。

目前的App Engine artifacts列在下面:

应用类型 Artifact 描述
App Engine app* guestbook-archetype 生成guestbook demo例子,完成并可以运行、测试
App Engine app* appengine-skeleton-archetype 为你自己的类和资源创建一个新的包含必须的文件和目录的空App Engine项目。
Cloud Endpints API backend hello-endpoints-archetype 一个Cloud Endpoints backend API 项目例子
Cloud Endpints API backend endpoints-skeleton-arhcetype 为你自己的类和资源创建一个新的包含必须的文件和目录的空Cloud Endpoints backend API 项目。

App Engine app*表示一个标准的App Engine app,不是Cloud Endpoints backend API。

向存在的Maven项目添加App Engine Maven Plugin

在项目的pom.xml文件中增加plugins部分:

<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.9.22</version>
</plugin>

指定本地测试的一个端口

本地运行的默认端口是8080,。可以通过修改appengine-maven-plugin条目来改变。

 <plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.9.22</version>
<configuration>
<enableJarClasses>false</enableJarClasses>
<port>8181</port>
<address>0.0.0.0</address>
</configuration>
</plugin>

此处将端口设置为8181;地址指定为0.0.0.0,这意味着development server将会侦听来自本地网络的请求。

使用App Engine Maven Plugin管理和运行一个项目

App Engine Maven Plugin支持在Maven中的App Engine。它提供了使用development server以及appcfg工具的大多数功能。

The plugin also provides Google Cloud Endpoints goals for discovery doc generation and client library generation.

一旦App Engine Maven Plugin被添加到了pom.xml中,一些Engine-specific Maven goals 就可以得到。查看所有可以获得的目标,调用命令:

mvn help:describe -Dplugin=appengine

App Engine Maven plugin 目标

App Engine Maven plugin 目标可以分类为devserver目标、应用和项目管理目标、Endpoints目标。

Development server目标

appengine:devserver

运行development server。当server运行时,它会继续检查appengine-web.xml是否发生了改变。这意味着appengine-web.xml发生改变时不需要停止再启动你的应用。

appengine:devserver_start

异步启动

appengine:devserver_stop

停止由appengine:devserver_start启动的development server

Troubleshooting upload errors

发生错误:404 Not Found This application does not exist (app_id=u'your-app-ID')

原因:有多个Google账户,使用了错误的账户

解决方法:切换到~目录,重命名.appcfg_oauth2_tokens_java之后再重试。

Using Apache Maven的更多相关文章

  1. maven install Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project web_nanchang

    maven打包成war时,报错:Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default- ...

  2. Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (dist) on project hadoop-kms: An Ant BuildException has occured

    编译cdh版hadoop2.5.0出现的问题 系统: CentOs66 64位 JDK:1.7 Maven: 3.0.5 Protobuf: libprotoc 2.5.0 编译命令: mvn pac ...

  3. eclipse加载maven工程提示pom.xml无法解析org.apache.maven.plugins:maven-resources-plugin:2.4.3解决方案

    pom文件提示信息: Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3 from http:/ ...

  4. Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project LogTest: Compilation failure -> [Help 1]

      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default ...

  5. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:

    security-sdk-1.0.jar已经存在于D:/secServerSDK-test/src/main/resources/lib下 报错如下: xxxxxx@xxxxxxxx /d/secSe ...

  6. maven Error resolving version for plugin 'org.apache.maven.plugins:maven-eclipse-plugin' from the repositories 解决

    报错:Error resolving version for plugin 'org.apache.maven.plugins:maven-eclipse-plugin' from the repos ...

  7. [Maven]Apache Maven 入门篇

    作者:George Ma 上 写这个 maven 的入门篇是因为之前在一个开发者会的动手实验中发现挺多人对于 maven 不是那么了解,所以就有了这个想法.这个入门篇分上下两篇.本文着重动手,用 ma ...

  8. apache maven pom setting

    <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Soft ...

  9. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create (default-cli) on project standalone-pom: Unable to parse configuration of 3: mojo org.apache.maven.plugins:

    问题: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create (defau ...

  10. Apache Maven 入门篇 ( 上 )

    作者:George Ma 写这个 maven 的入门篇是因为之前在一个开发者会的动手实验中发现挺多人对于 maven 不是那么了解,所以就有了这个想法. 这个入门篇分上下两篇.本文着重动手,用 mav ...

随机推荐

  1. iOS iOS7越狱

    1.使用盘古越狱工具 (或者PP助手) 2.越狱成功后需要安装Apple File Conduit “2”,用于替代afc2add插件 3.安装AppSync插件 (绕过系统验证,随意安装.运行破解的 ...

  2. ActiveMQ 集群(1)

    Queue consumer clusters(消费者集群): 简介: 同一个queue,如果一个消费者失效, 那么任何未经确认的消息将会被发送给queue上的其它消费者.如果一个消费者比其它消费者执 ...

  3. VS2015中快捷注释代码块

    注释ctrl+k   ctrl+c 反注释ctrl+k ctrl+u 需要注意的是第二个ctrl不能省略的

  4. VS2012安装英文的语言包后,调试的时候提示Unknown error:0x80040d10

    https://social.msdn.microsoft.com/Forums/en-US/e11a86ef-3be2-4256-92e9-d12809f2a6ca/error-0x80040d10 ...

  5. mysql 查看警告

    显示警告(打开): warnings 查看警告(查看内容): show warnings; 记录运行日志: tee  _logsfile source sql_filenotee

  6. Effective C++学习笔记 条款04:确定对象被使用前已先被初始化

    一.为内置类型对象进行手工初始化,因为C++不保证初始化它们. 二.对象初始化数据成员是在进入构造函数用户编写代码前完成,要想对数据成员指定初始化值,那就必须使用初始化列表. class A { pu ...

  7. Android UI学习 - FrameLayou和布局优化(viewstub)

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://android.blog.51cto.com/268543/308090 Fram ...

  8. HDU 1698 Just a Hook (线段树 成段更新 lazy-tag思想)

    题目链接 题意: n个挂钩,q次询问,每个挂钩可能的值为1 2 3,  初始值为1,每次询问 把从x到Y区间内的值改变为z.求最后的总的值. 分析:用val记录这一个区间的值,val == -1表示这 ...

  9. java--关键字和保留字

    关键字:Java的关键字对java的编译器有特殊的意义,他们用来表示一种数据类型,或者表示程序的结构等. 保留字:为java预留的关键字.现在还没用到,但是在升级版本中可能作为关键字. 访问控制:pr ...

  10. LA 5009 (三分法求极值) Error Curves

    给出的曲线要么是开口向上的抛物线要么是直线,但所定义的F(x)的图形一定是下凸的. 注意一点就是求得是极小值,而不是横坐标,样例也很容易误导人. #include <cstdio> #in ...