是否可以使用 appengine 模块和云端点?

2023-11-29

使用 appengine 模块意味着创建动态 Web 应用程序,而不是通常的 appengine Web 应用程序项目。云端点与常见的 appengine Web 应用程序项目配合良好,但这些项目不支持 appengine 模块。

问题是,如果我尝试在动态 Web 应用程序上生成云端点客户端库,则会收到错误“不是 App Engine 项目”。

有没有什么方法可以让动态 Web 应用程序被识别为 App Engine 项目,以便可以在其上生成云端点客户端库?


目前正在解决同样的问题,我想我已经找到了具有以下设置的解决方案(使用 Maven 作为 java 项目):

在项目根 pom.xml 中:定义了一些常见值(例如您正在使用的 appengine 版本),pom包装和模块,尤其是 EAR 模块:

<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>myproject-root</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>myproject-root</name>

<properties>
    <appengine.app.version>1</appengine.app.version>
    <appengine.target.version>1.9.11</appengine.target.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<modules>
    <module>myproject-ear</module>
    <module>myproject-cloud-endpoints</module>
    <module>myproject-backend</module>
</modules>

</project>

EAR 模块的 pom.xml 当然应该有 EAR 打包,但也应该有对其他模块的“war”类型依赖,并且 maven-ear 插件的“unpack types”选项设置为“war”:

<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.example</groupId>
    <artifactId>myproject-root</artifactId>
    <version>1.0</version>
</parent>

<groupId>com.example</groupId>
<artifactId>myproject-ear</artifactId>
<version>1.0</version>
<packaging>ear</packaging>

<name>myproject-ear</name>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <version>5</version>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <unpackTypes>war</unpackTypes>
                <applicationXml>${project.basedir}/src/main/application/META-INF/maven-application.xml</applicationXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>${appengine.target.version}</version>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>com.example</groupId>
        <artifactId>myproject-cloud-endpoints</artifactId>
        <version>1.0</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>com.example</groupId>
        <artifactId>myproject-backend</artifactId>
        <version>1.0</version>
        <type>war</type>
    </dependency>
</dependencies>
<properties/>
</project>

最后,“cloud-endpoints”pom.xml 应配置为带有“war”打包的基本云端点 webapp 项目:

<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.example</groupId>
    <artifactId>myproject-root</artifactId>
    <version>1.0</version>
</parent>

<groupId>com.example</groupId>
<artifactId>myproject-cloud-endpoints</artifactId>
<version>1.0</version>
<packaging>war</packaging>

<name>myproject-cloud-endpoints</name>

<dependencies>
    <!-- Compile/runtime dependencies -->
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-1.0-sdk</artifactId>
        <version>${appengine.target.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-endpoints</artifactId>
        <version>${appengine.target.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>
</dependencies>


<build>
    <!-- for hot reload of the web application in devserver-->
    <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>display-dependency-updates</goal>
                        <goal>display-plugin-updates</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <version>3.1</version>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml>
                <webResources>
                    <resource>
                        <!-- this is relative to the pom.xml directory -->
                        <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory>
                        <!-- the list has a default value of ** -->
                        <includes>
                            <include>WEB-INF/*.discovery</include>
                            <include>WEB-INF/*.api</include>
                        </includes>
                    </resource>
                </webResources>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>${appengine.target.version}</version>
            <configuration>
                <enableJarClasses>false</enableJarClasses>
                <!-- Comment in the below snippet to bind to all IPs instead of just localhost -->
                <!-- address>0.0.0.0</address>
                <port>8080</port -->
                <!-- Comment in the below snippet to enable local debugging with a remove debugger
                     like those included with Eclipse or IntelliJ -->
                <!-- jvmFlags>
                  <jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag>
                </jvmFlags -->
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>endpoints_get_discovery_doc</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

构建此项目后,您应该能够通过 Eclipse 生成云端点客户端库:右键单击“cloud-endpoints”项目=>“谷歌应用程序引擎 WTP" => "生成 Cloud Endpoint 客户端库" 将生成myproject-cloud-endpoints/endpoint-libs/.

希望有帮助!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

是否可以使用 appengine 模块和云端点? 的相关文章

随机推荐

  • csv 读取引发“UnicodeDecodeError:'charmap'编解码器无法解码...”

    我已经阅读了我能找到的所有帖子 但我的情况似乎很独特 我对 Python 完全陌生 所以这可能是基础的 我收到以下错误 UnicodeDecodeError charmap 编解码器无法解码位置 70 中的字节 0x8d 字符映射到未定义
  • 如何将日期选择器包装在新的 div 中?

    我需要将我的日期选择器放在一个新的 div 中 这将是一个 shadow border div 我尝试过以下方法 beforeShow function input input datepicker widget find ui datep
  • 最大字符串数组 VisualBasic WSH

    我正在 VB 中编写一个 WSH 脚本 以读取通过 Run 方法使用重定向目录列表生成的大量目录列表 目录列表大约有 8400 行 但是每次我运行脚本时 都会出现以下循环 执行直到 DirList AtEndOfStream Redim 保
  • 我可以手动注册/安装 Search.Collat​​orDSO.1

    我目前正在尝试使用 windows search 服务搜索一些索引文件 我的问题是 Windows 搜索无法安装在网络服务器上 因为它是 网络版本 收到的错误消息是 Search Collat orDSO 1 提供程序未在本地计算机上注册
  • Windows 忽略 JAVA_HOME:如何将 JDK 设置为默认值?

    如何说服 Windows 使用 JDK 而不是 JRE 这个问题之前已经在这里和其他地方被问过 如何设置默认 Java 安装 运行时 Windows 问题是 Windows 忽略了JAVA HOME它还忽略了我将 JDK bin 目录作为路
  • 如何检测Android是否完全支持USB?

    我的应用程序使用UsbManager与 USB 摄像头通信 有些设备不支持 USB 这些将返回null for UsbManager context getSystemService Context USB SERVICE 或者他们会抛出一
  • 放大 Plotly 热图

    目前 Plotly JS 热图中有 2 种 缩放 行为 在这里 您可以采用任何矩形形状进行缩放 单击 拖放 但是像素不是正方形的 这对于某些应用程序来说是不行的 不保留长宽比 有时应该保留 const z Array from length
  • 为什么在隐含时使用媒体查询类型“all”?

    我最近注意到我一直在使用all在每一个 media查询规则 我不明白为什么我这样做 我在网上搜索过 我发现大多数 media网络上的规则示例使用如下格式 media all and some other condition 为什么有媒体类型
  • 在 Firebase 中随机配对用户[关闭]

    Closed 这个问题需要细节或清晰度 目前不接受答案 我正在使用 Flutter 和 Firebase 开发一个应用程序 我必须解决一个听起来像这样的问题 每个用户 在任何时候 都可以将自己置于等候名单 Firebase 必须通过以下方式
  • 使用正则表达式在 Visual Studio Code 中设置代码片段

    Comment prefix body 我已经设置了about代码片段 目的是添加注释 添加文件的基目录和文件名像这样但丢弃路径的其余部分 我相信这最初是基于 TextMate 片段 我已经尝试了一切 但我无法让它工作 这可能是愚蠢的事情
  • 在两个固定 div 元素之间创建滚动 div

    我对在网站中如何定位 div 不太熟悉 所以我希望有人可以在这里提供帮助 我想要得到的是一个三明治类型的设置 在两个 div 中间有一个滚动内容 这样我就有一个页眉 div 和一个页脚 div 它们都必须在页面上保持静态 然后 在它们之间
  • 一个组件可以有多个模板吗?

    有没有办法让 Angular 2 组件根据我想要放置的位置使用许多模板文件 例如 我有一个login组件 我想用两种不同的设计将其放置在我的网站上两次 有没有一种方法可以将模板传递给组件 不确定 NG2 是否有内置方法来支持这一点 我只是使
  • 在 C# 中检测(通过反射)Enum 类型是否为“Flags”类型的策略

    我使用反射来读取程序集中的类型 以生成代码 我可以看到一些枚举应该标有 Flags 属性 但编写这些枚举的人忘记添加此属性 有没有可靠的方法来检测枚举何时可以被视为 标志 枚举 我目前的策略是按降序读取枚举 并检查 element last
  • 如何生成 R 计数矩阵

    在 R 中 我可以使用我感兴趣的特定列名称作为数组返回计数结果 如下所示 require plyr bevs lt data frame cbind name c Bill Llib drink c coffee tea cocoa wat
  • 从 Java 游戏中删除对象(Eclipse)

    让我们开始吧 我有一个 处理程序 类 它充满了 getter 和 setter 并且其中包含添加和删除对象的代码 它看起来像这样 public void addObject GameObject object this object add
  • 尝试创建下拉菜单 pygame,但卡住了

    到目前为止 这是我的代码 import pygame as pg pg init clock pg time Clock Generating screen w scr 640 h scr 480 size scr w scr h scr
  • 在 Firefox 中禁用跨域 Web 安全

    在 Firefox 中 我该如何做相当于 disable web security在 Chrome 中 这个问题已经被发布了很多次 但从来没有一个真正的答案 大多数是附加组件的链接 其中一些在最新的 Firefox 中不起作用或根本不起作用
  • 如何在 Julia 中使用 JuMP 提取优化问题矩阵 A,b,c

    我使用符号变量和约束在 Julia JuMP 中创建了一个优化模型 例如以下 using JuMP using CPLEX model Mod Model CPLEX Optimizer sets I 1 2 Variables x var
  • Perl 中的读写锁

    我正在寻找一种在 Perl 中实现读 写锁的好方法 这是同步 Windows 和 Unix 上不同 Perl 线程和 或进程的文件访问所必需的 尝试过 Fcntl flock 如果它按预期工作 这对我来说将是完美的 不幸的是 看起来在压力下
  • 是否可以使用 appengine 模块和云端点?

    使用 appengine 模块意味着创建动态 Web 应用程序 而不是通常的 appengine Web 应用程序项目 云端点与常见的 appengine Web 应用程序项目配合良好 但这些项目不支持 appengine 模块 问题是 如