在AppEngine上使用谷歌云终端

时间:2020-12-26 23:13:14

I normally use Google Cloud Endpoints on the AppEngine (Java) , as described in :

我通常在AppEngine(Java)上使用Google Cloud Endpoints,如下所述:

https://cloud.google.com/appengine/docs/java/endpoints/helloendpoints-java-maven

https://cloud.google.com/appengine/docs/java/endpoints/helloendpoints-java-maven

The dependency for the endpoints library I use is :

我使用的端点库的依赖关系是:

<plugin>
   <groupId>com.google.appengine</groupId>
   <artifactId>appengine-endpoints</artifactId>
   <version>1.9.48</version>
</plugin>

Using this, I can start a local development server using the command: mvn clean package appengine:devserver

使用此命令,我可以使用以下命令启动本地开发服务器:mvn clean package appengine:devserver

However, there seems to be a new version of cloud endpoints. https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java .

但是,似乎有一个新版本的云端点。 https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java。

The new framework is found here

新框架可在此处找到

<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>${endpoints.framework.version}</version>
</dependency>

The same maven commands do not work here. I am unable to start a local dev server, open the API explorer or use a local datastore (all of which was possible earlier) . Could someone please guide me on how to work with the new framework.

相同的maven命令在这里不起作用。我无法启动本地开发服务器,打开API资源管理器或使用本地数据存储区(所有这些都可能更早)。有人可以指导我如何使用新框架。

Also, is the former framework likely to be deprecated ?

此外,前框架是否可能被弃用?

2 个解决方案

#1


4  

There are a few problems you are running into and this stuff is overly sensitive to configuration issues:

您遇到了一些问题,这些问题对配置问题过于敏感:

To solve the problems follow the instructions in: https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java

要解决问题,请按照以下说明操作:https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java

  1. Use the correct Google project id when you replace the YOUR_PROJECT_ID in pom.xml. It needs to be a valid project id for all the steps to work.
  2. 替换pom.xml中的YOUR_PROJECT_ID时,请使用正确的Google项目ID。它必须是所有步骤的有效项目ID。
  3. Same when replacing the YOUR-PROJECT-ID in echo.java
  4. 替换echo.java中的YOUR-PROJECT-ID时相同

If the project id is not valid (actually exists in AppEngine) the next steps won't work

如果项目ID无效(实际存在于AppEngine中),则后续步骤将不起作用

  1. execute: mvn exec:java -DGetSwaggerDoc
  2. 执行:mvn exec:java -DGetSwaggerDoc
  3. execute: gcloud service-management deploy openapi.json
  4. 执行:gcloud service-management部署openapi.json
  5. execute: export ENDPOINTS_SERVICE_NAME=echo-api.endpoints.<your project id>.cloud.goog
  6. 执行:export ENDPOINTS_SERVICE_NAME = echo-api.endpoints。 <您的项目id> .cloud.goog

The quickstart guide is not very helpful for step 5. Step 4 needs to end with a success message.

快速入门指南对步骤5没有多大帮助。步骤4需要以成功消息结束。

Finally the sample comes with a Maven plugin that does not seem to work with the new Endpoints. Instead of using:

最后,该示例附带了一个Maven插件,该插件似乎不适用于新的端点。而不是使用:

    <plugin>
        <groupId>com.google.cloud.tools</groupId>
        <artifactId>appengine-maven-plugin</artifactId>
        <version>${appengine.maven.plugin.version}</version>
    </plugin>

use:

使用:

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

The answer to the question why mvn appengine:devserver doesn't work is that the devserver target doesn't exist in the new plugin. The old Maven plugin allows you to execute: mvn appengine:devserver

mvn appengine:devserver无效的问题的答案是新插件中不存在devserver目标。旧的Maven插件允许您执行:mvn appengine:devserver

#2


6  

To answer my own question partially : I could finally get the "Echo application" (mentioned in https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java) to work

部分回答我自己的问题:我终于可以使用“Echo应用程序”(在https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java中提到)来工作

But I had to make 2 changes: a) Comment out the block in appengine-web.xml . ie,

但是我必须进行2次更改:a)在appengine-web.xml中注释掉该块。即

<!--
<basic-scaling>
  <max-instances>2</max-instances>
</basic-scaling>
-->

After doing this, I got a different error, "failed endpoints-api-configuration: com.google.api.config.ServiceConfigException: Failed to fetch default config version for service" To get around this :

执行此操作后,我得到了一个不同的错误,“失败的端点-api-configuration:com.google.api.config.ServiceConfigException:无法获取服务的默认配置版本”为了解决这个问题:

b) Comment out the ServiceManagementConfigFilter from web.xml , ie,

b)从web.xml注释掉ServiceManagementConfigFilter,即

<!--
    <filter>
      <filter-name>endpoints-api-configuration</filter-name>
      <filter-class>com.google.api.control.ServiceManagementConfigFilter</filter-class>
   </filter>
-->
<!--    
<filter-mapping>
    <filter-name>endpoints-api-configuration</filter-name>
    <servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>
-->

After this,

在这之后,

  1. To build : mvn clean package

    要构建:mvn clean包

  2. To run locally : appengine-java-sdk/1.9.44/appengine-java-sdk/appengine-java-sdk-1.9.44/bin/dev_appserver.sh /path/to/war/directory

    在本地运行:appengine-java-sdk / 1.9.44 / appengine-java-sdk / appengine-java-sdk-1.9.44 / bin / dev_appserver.sh / path / to / war / directory

It would be great if someone could shed more light on implication of these changes, and on how we could get it to work out of the box

如果有人能够更清楚地了解这些变化的含义,以及我们如何让它开箱即用,那将会很棒

#1


4  

There are a few problems you are running into and this stuff is overly sensitive to configuration issues:

您遇到了一些问题,这些问题对配置问题过于敏感:

To solve the problems follow the instructions in: https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java

要解决问题,请按照以下说明操作:https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java

  1. Use the correct Google project id when you replace the YOUR_PROJECT_ID in pom.xml. It needs to be a valid project id for all the steps to work.
  2. 替换pom.xml中的YOUR_PROJECT_ID时,请使用正确的Google项目ID。它必须是所有步骤的有效项目ID。
  3. Same when replacing the YOUR-PROJECT-ID in echo.java
  4. 替换echo.java中的YOUR-PROJECT-ID时相同

If the project id is not valid (actually exists in AppEngine) the next steps won't work

如果项目ID无效(实际存在于AppEngine中),则后续步骤将不起作用

  1. execute: mvn exec:java -DGetSwaggerDoc
  2. 执行:mvn exec:java -DGetSwaggerDoc
  3. execute: gcloud service-management deploy openapi.json
  4. 执行:gcloud service-management部署openapi.json
  5. execute: export ENDPOINTS_SERVICE_NAME=echo-api.endpoints.<your project id>.cloud.goog
  6. 执行:export ENDPOINTS_SERVICE_NAME = echo-api.endpoints。 <您的项目id> .cloud.goog

The quickstart guide is not very helpful for step 5. Step 4 needs to end with a success message.

快速入门指南对步骤5没有多大帮助。步骤4需要以成功消息结束。

Finally the sample comes with a Maven plugin that does not seem to work with the new Endpoints. Instead of using:

最后,该示例附带了一个Maven插件,该插件似乎不适用于新的端点。而不是使用:

    <plugin>
        <groupId>com.google.cloud.tools</groupId>
        <artifactId>appengine-maven-plugin</artifactId>
        <version>${appengine.maven.plugin.version}</version>
    </plugin>

use:

使用:

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

The answer to the question why mvn appengine:devserver doesn't work is that the devserver target doesn't exist in the new plugin. The old Maven plugin allows you to execute: mvn appengine:devserver

mvn appengine:devserver无效的问题的答案是新插件中不存在devserver目标。旧的Maven插件允许您执行:mvn appengine:devserver

#2


6  

To answer my own question partially : I could finally get the "Echo application" (mentioned in https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java) to work

部分回答我自己的问题:我终于可以使用“Echo应用程序”(在https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java中提到)来工作

But I had to make 2 changes: a) Comment out the block in appengine-web.xml . ie,

但是我必须进行2次更改:a)在appengine-web.xml中注释掉该块。即

<!--
<basic-scaling>
  <max-instances>2</max-instances>
</basic-scaling>
-->

After doing this, I got a different error, "failed endpoints-api-configuration: com.google.api.config.ServiceConfigException: Failed to fetch default config version for service" To get around this :

执行此操作后,我得到了一个不同的错误,“失败的端点-api-configuration:com.google.api.config.ServiceConfigException:无法获取服务的默认配置版本”为了解决这个问题:

b) Comment out the ServiceManagementConfigFilter from web.xml , ie,

b)从web.xml注释掉ServiceManagementConfigFilter,即

<!--
    <filter>
      <filter-name>endpoints-api-configuration</filter-name>
      <filter-class>com.google.api.control.ServiceManagementConfigFilter</filter-class>
   </filter>
-->
<!--    
<filter-mapping>
    <filter-name>endpoints-api-configuration</filter-name>
    <servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>
-->

After this,

在这之后,

  1. To build : mvn clean package

    要构建:mvn clean包

  2. To run locally : appengine-java-sdk/1.9.44/appengine-java-sdk/appengine-java-sdk-1.9.44/bin/dev_appserver.sh /path/to/war/directory

    在本地运行:appengine-java-sdk / 1.9.44 / appengine-java-sdk / appengine-java-sdk-1.9.44 / bin / dev_appserver.sh / path / to / war / directory

It would be great if someone could shed more light on implication of these changes, and on how we could get it to work out of the box

如果有人能够更清楚地了解这些变化的含义,以及我们如何让它开箱即用,那将会很棒