lib 和 类 文件夹是使用 IntelliJ 暂存和部署的,但 gcloud 命令不包括它们
The lib and classes folders are staged and deployed with IntelliJ but gcloud command does not include them
我有一个 Java 8 Spring Boot GAE 标准应用程序,我使用 IntelliJ IDE(用于 GAE 应用程序的云代码插件)。
我使用 AppEngine-web.xml.
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
<sessions-enabled>true</sessions-enabled>
<runtime>java8</runtime>
<application>***</application>
<service>***</service>
<version>***</version>
<url-stream-handler>urlfetch</url-stream-handler>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
<async-session-persistence enabled="true" />
<instance-class>F2</instance-class>
<resource-files>
<include path="/**.json" />
</resource-files>
<use-google-connector-j>true</use-google-connector-j>
<env-variables>
<env-var name="GOOGLE_APPLICATION_CREDENTIALS"
value="WEB-INF/***.json" />
</env-variables>
</appengine-web-app>
当我使用 IntelliJ 部署我的 GAE 应用程序时,这些文件夹是在我的暂存中生成的,一切正常;
这是我在 IntelliJ 上的 运行 配置的快照
当我使用 gcloud 命令部署它时出现问题:
gcloud app deploy src/main/webapp/WEB-INF/appengine-web.xml --version=something --promote --stop-previous-version --verbosity=debug
这里是生成的暂存文件夹:
我的应用程序根目录中有 .gitignore
文件;我删除了它以检查它是否正在创建问题并且没有运气,我也对 .cloudignore
.
做了同样的事情
gcloud deploy 跳过文件,输出如下:
DEBUG: Loading runtimes experiment config from [gs://runtime-builders/experiments.yaml]
INFO: Reading [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]
DEBUG:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\runtime_builders.py", line 269, in _Read
with contextlib.closing(storage_client.ReadObject(object_)) as f:
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\storage\storage_api.py", line 317, in ReadObject
object_=object_ref, err=http_exc.HttpException(err)))
BadFileException: Could not read [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]. Please retry: HTTPError 404: No such object: runtime-builders/experiments.yaml
DEBUG: Experiment config file could not be read. This error is informational, and does not cause a deployment to fail. Reason: Unable to read the runtimes experiment config: [gs://runtime-builders/experiments.yaml], error: Could not read [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]. Please retry: HTTPError 404: No such object: runtime-builders/experiments.yaml
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\surface\app\deploy.py", line 146, in _ServerSideExperimentEnabled
runtimes_builder_root)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\runtime_builders.py", line 524, in LoadFromURI
.format(uri, e))
ExperimentsError: Unable to read the runtimes experiment config: [gs://runtime-builders/experiments.yaml], error: Could not read [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]. Please retry: HTTPError 404: No such object: runtime-builders/experiments.yaml
WARNING: <application> and <version> elements in `appengine-web.xml` are not respected
INFO: Executing staging command: [C:\Program Files\Common Files\Oracle\Java\javapath\java.exe -classpath C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\java\lib\appengine-tools-api.jar com.google.appengine.tools.admin.AppCfg --enable_new_staging_defaults stage E:***\src\main\webapp c:\users\***\appdata\local\temp\tmp1nhtxn\tmpoizcfc]
DEBUG: Executing command: [u'C:\Program Files\Common Files\Oracle\Java\javapath\java.exe', u'-classpath', u'C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\java\lib\appengine-tools-api.jar', u'com.google.appengine.tools.admin.AppCfg', u'--enable_new_staging_defaults', u'stage', u'E:***\src\main\webapp', 'c:\users\***\appdata\local\temp\tmp1nhtxn\tmpoizcfc']
INFO: ------------------------------------ STDOUT ------------------------------------
Reading application configuration data...
Beginning interaction for module ***...
0% Scanning for jsp files.
2021-12-22 15:11:47.738:INFO::main: Logging initialized @167ms to org.eclipse.jetty.util.log.StdErrLog
2021-12-22 15:11:48.115:INFO:oeja.AnnotationConfiguration:main: Scanning elapsed time=0ms
0% Generated git repository information file.
Success.
Temporary staging for module *** directory left in C:\Users\***\AppData\Local\Temp\tmp1nhtxn\tmpoizcfc
------------------------------------ STDERR ------------------------------------
2021-12-22 15:11:47.221:INFO::main: Logging initialized @725ms to org.eclipse.jetty.util.log.StdErrLog
--------------------------------------------------------------------------------
我已经设法在同一个项目中复制了这个类似的问题。这是因为 Java 8 可能被认为是旧版本,但最佳实践仍然适用,即在提交部署时使用 App Engine Maven 插件。可以通过此 link.
找到完整的文档
我更改了 gcloud 命令:
gcloud app deploy src/main/webapp/WEB-INF/appengine-web.xml
--version=something --promote --stop-previous-version --verbosity=debug
为此:
mvn clean package appengine:deploy
此过程需要一些时间,因为它会在部署项目之前清理并重新安装包。
这是一个 Github link 与您的项目类似的项目,您可以尝试一下,因为这个对我有用。
编辑:
Google Java 8 的 App Maven 插件仍然基于此 Github link.
定期更新
独立的 App Engine SDK 和基于它的 Maven 插件 (com.google.appengine:appengine-maven-plugin
) 现已关闭。您必须使用 Cloud SDK 工具并迁移到基于 Cloud SDK 的 Maven 插件 (com.google.cloud.tools:appengine-maven-plugin
)。可以通过此 link on how to use Maven.
找到完整的描述和步骤
这就是为什么我们使用 mvn clean package appengine:deploy
非常重要的原因。
我还会包含来自 pom.xml
的代码片段,其中包含您需要设置的配置:
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<projectId>GCLOUD_CONFIG</projectId>
<version>GCLOUD_CONFIG</version>
<deploy.promote>true</deploy.promote>
<deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
</configuration>
</plugin>
完整的文档可以通过这个找到link containing sample Java codes for handling requests
此外,Intellij 还使用了一个名为 Cloud Code 的 Google Cloud 插件,这是一个与 Maven 类似的插件。
我已尝试部署 app.yaml
文件,但出现此错误:
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT:
WEB-INF/appengine-web.xml is required for this runtime.
总体而言,如果要部署 Java 8 项目,则无法使用 gcloud 工具。如果真的要用gcloud,需要升级到Java11.
以下是我用来复制此项目的其他参考资料:
我有一个 Java 8 Spring Boot GAE 标准应用程序,我使用 IntelliJ IDE(用于 GAE 应用程序的云代码插件)。
我使用 AppEngine-web.xml.
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
<sessions-enabled>true</sessions-enabled>
<runtime>java8</runtime>
<application>***</application>
<service>***</service>
<version>***</version>
<url-stream-handler>urlfetch</url-stream-handler>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
<async-session-persistence enabled="true" />
<instance-class>F2</instance-class>
<resource-files>
<include path="/**.json" />
</resource-files>
<use-google-connector-j>true</use-google-connector-j>
<env-variables>
<env-var name="GOOGLE_APPLICATION_CREDENTIALS"
value="WEB-INF/***.json" />
</env-variables>
</appengine-web-app>
当我使用 IntelliJ 部署我的 GAE 应用程序时,这些文件夹是在我的暂存中生成的,一切正常;
这是我在 IntelliJ 上的 运行 配置的快照
当我使用 gcloud 命令部署它时出现问题:
gcloud app deploy src/main/webapp/WEB-INF/appengine-web.xml --version=something --promote --stop-previous-version --verbosity=debug
这里是生成的暂存文件夹:
我的应用程序根目录中有 .gitignore
文件;我删除了它以检查它是否正在创建问题并且没有运气,我也对 .cloudignore
.
gcloud deploy 跳过文件,输出如下:
DEBUG: Loading runtimes experiment config from [gs://runtime-builders/experiments.yaml]
INFO: Reading [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]
DEBUG:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\runtime_builders.py", line 269, in _Read
with contextlib.closing(storage_client.ReadObject(object_)) as f:
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\storage\storage_api.py", line 317, in ReadObject
object_=object_ref, err=http_exc.HttpException(err)))
BadFileException: Could not read [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]. Please retry: HTTPError 404: No such object: runtime-builders/experiments.yaml
DEBUG: Experiment config file could not be read. This error is informational, and does not cause a deployment to fail. Reason: Unable to read the runtimes experiment config: [gs://runtime-builders/experiments.yaml], error: Could not read [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]. Please retry: HTTPError 404: No such object: runtime-builders/experiments.yaml
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\surface\app\deploy.py", line 146, in _ServerSideExperimentEnabled
runtimes_builder_root)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\runtime_builders.py", line 524, in LoadFromURI
.format(uri, e))
ExperimentsError: Unable to read the runtimes experiment config: [gs://runtime-builders/experiments.yaml], error: Could not read [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000006BB8988>]. Please retry: HTTPError 404: No such object: runtime-builders/experiments.yaml
WARNING: <application> and <version> elements in `appengine-web.xml` are not respected
INFO: Executing staging command: [C:\Program Files\Common Files\Oracle\Java\javapath\java.exe -classpath C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\java\lib\appengine-tools-api.jar com.google.appengine.tools.admin.AppCfg --enable_new_staging_defaults stage E:***\src\main\webapp c:\users\***\appdata\local\temp\tmp1nhtxn\tmpoizcfc]
DEBUG: Executing command: [u'C:\Program Files\Common Files\Oracle\Java\javapath\java.exe', u'-classpath', u'C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\java\lib\appengine-tools-api.jar', u'com.google.appengine.tools.admin.AppCfg', u'--enable_new_staging_defaults', u'stage', u'E:***\src\main\webapp', 'c:\users\***\appdata\local\temp\tmp1nhtxn\tmpoizcfc']
INFO: ------------------------------------ STDOUT ------------------------------------
Reading application configuration data...
Beginning interaction for module ***...
0% Scanning for jsp files.
2021-12-22 15:11:47.738:INFO::main: Logging initialized @167ms to org.eclipse.jetty.util.log.StdErrLog
2021-12-22 15:11:48.115:INFO:oeja.AnnotationConfiguration:main: Scanning elapsed time=0ms
0% Generated git repository information file.
Success.
Temporary staging for module *** directory left in C:\Users\***\AppData\Local\Temp\tmp1nhtxn\tmpoizcfc
------------------------------------ STDERR ------------------------------------
2021-12-22 15:11:47.221:INFO::main: Logging initialized @725ms to org.eclipse.jetty.util.log.StdErrLog
--------------------------------------------------------------------------------
我已经设法在同一个项目中复制了这个类似的问题。这是因为 Java 8 可能被认为是旧版本,但最佳实践仍然适用,即在提交部署时使用 App Engine Maven 插件。可以通过此 link.
找到完整的文档我更改了 gcloud 命令:
gcloud app deploy src/main/webapp/WEB-INF/appengine-web.xml
--version=something --promote --stop-previous-version --verbosity=debug
为此:
mvn clean package appengine:deploy
此过程需要一些时间,因为它会在部署项目之前清理并重新安装包。
这是一个 Github link 与您的项目类似的项目,您可以尝试一下,因为这个对我有用。
编辑:
Google Java 8 的 App Maven 插件仍然基于此 Github link.
定期更新独立的 App Engine SDK 和基于它的 Maven 插件 (com.google.appengine:appengine-maven-plugin
) 现已关闭。您必须使用 Cloud SDK 工具并迁移到基于 Cloud SDK 的 Maven 插件 (com.google.cloud.tools:appengine-maven-plugin
)。可以通过此 link on how to use Maven.
这就是为什么我们使用 mvn clean package appengine:deploy
非常重要的原因。
我还会包含来自 pom.xml
的代码片段,其中包含您需要设置的配置:
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<projectId>GCLOUD_CONFIG</projectId>
<version>GCLOUD_CONFIG</version>
<deploy.promote>true</deploy.promote>
<deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
</configuration>
</plugin>
完整的文档可以通过这个找到link containing sample Java codes for handling requests 此外,Intellij 还使用了一个名为 Cloud Code 的 Google Cloud 插件,这是一个与 Maven 类似的插件。
我已尝试部署 app.yaml
文件,但出现此错误:
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT:
WEB-INF/appengine-web.xml is required for this runtime.
总体而言,如果要部署 Java 8 项目,则无法使用 gcloud 工具。如果真的要用gcloud,需要升级到Java11.
以下是我用来复制此项目的其他参考资料: