我有一個 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
--------------------------------------------------------------------------------
uj5u.com熱心網友回復:
我設法在同一個專案上復制了這個類似的問題。這是因為 Java 8 可能被視為舊版本,但最佳實踐仍然適用,即在提交部署時使用 App Engine Maven 插件。可以通過此鏈接找到完整的檔案。
我已經更改了 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 鏈接,您可以在最后嘗試,因為這個鏈接對我有用。
編輯:
適用于 Java 8 的 Google App Maven 插件仍會根據此Github 鏈接定期更新。
獨立的 App Engine SDK 和com.google.appengine:appengine-maven-plugin基于它的 Maven 插件 ( ) 現在已關閉。您必須使用 Cloud SDK 工具并遷移到基于 Cloud SDK 的 Maven 插件 ( com.google.cloud.tools:appengine-maven-plugin)。通過此鏈接可以找到有關如何使用 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>
可以通過此鏈接找到完整的檔案,其中包含用于處理請求的示例 Java 代碼。 此外,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,你需要升級到 Java 11。
以下是我用來復制此專案的其他參考資料:
- https://cloud.google.com/appengine/docs/standard/java/runtime
- https://cloud.google.com/appengine/docs/standard/java/config/appref
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/392215.html
