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. 49. Anagrams

    题目: Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will ...

  2. Tomcat集群配置学习篇-----分布式应用

    Tomcat集群配置学习篇-----分布式应用 现目前基于javaWeb开发的应用系统已经比比皆是,尤其是电子商务网站,要想网站发展壮大,那么必然就得能够承受住庞大的网站访问量:大家知道如果服务器访问 ...

  3. Java API —— 多线程

    1.多线程概述     1)进程:         正在运行的程序,是系统进行资源分配和调用的独立单位.         每一个进程都有它自己的内存空间和系统资源.     2)线程:         ...

  4. linux下的共享库(动态库)和静态库

    1.什么是库在windows平台和linux平台下都大量存在着库.本质上来说库是一种可执行代码的二进制形式,可以被操作系统载入内存执行.由于windows和linux的本质不同,因此二者库的二进制是不 ...

  5. uboot---linux

    01uboot是没有虚拟地址的 02内存映射是linux内核的机制,也就是从实地址到虚拟地址是linux完成的! -----

  6. 自定义View(1)简单流程及示例模板

    1,继承View , ViewGroup,或TextView等等 2,绘制相关的api, canvas 画布, paint 画笔 2,重写重要的函数(注意这个顺序) onMeasure 属于View的 ...

  7. Oracle 多实例如何通过EM进行访问-portlist.ini

    [root@redhat4 install]# pwd/u01/app/oracle/product/11.2.0/dbhome_1/install[root@redhat4 install]# mo ...

  8. Python转义字符

    在需要在字符中使用特殊字符时,python用反斜杠(\)转义字符.有时我们并不想让转义字符生效,我们只想显示字符串原来的意思,这就要用r和R来定义原始字符串.如:print r'\t\r'实际输出为“ ...

  9. C++ STL之查找算法

    C++STL有好几种查找算法,但是他们的用法上有很多共同的地方: 1.除了binary_search的返回值是bool之外(查找的了返回true,否则返回false),其他所有的查找算法返回值都是一个 ...

  10. Relativelayout属性

    // 相对于给定ID控件 android:layout_above 将该控件的底部置于给定ID的控件之上; android:layout_below 将该控件的底部置于给定ID的控件之下; andro ...