簡體   English   中英

無法讓 Spring 引導應用程序在 Google Cloud Platform Flexible Environment 上工作

[英]Can't get Spring Boot application to work on Google Cloud Platform Flexible Environment

我在 Google Cloud Platform Flexible 環境中部署我的 Spring Boot 應用程序時遇到問題。

我運行以下命令進行部署: mvn clean compile package -DskipTests appengine:deploy -P cloud-gcp

我的 pom.xml 中的cloud-gcp配置文件具有以下內容:

<profiles>
        <profile>
            <id>cloud-gcp</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.google.cloud.tools</groupId>
                        <artifactId>appengine-maven-plugin</artifactId>
                        <version>1.3.2</version>
                        <configuration>
                            <version>beta3</version>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

這是我的app.yaml文件,位於src/main/appengine/app.yaml

runtime: java
env: flex
runtime_config:
  jdk: openjdk8
env_variables:
  SPRING_PROFILES_ACTIVE: "gcp"

handlers:
- url: /.*
  script: this field is required, but ignored
manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 4
  disk_size_gb: 10

這是我的application-gcp.properties

server.address=0.0.0.0
server.port=8080

# Datasource
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect
spring.datasource.username=xxx
spring.datasource.password=xxx
spring.datasource.url=jdbc:postgresql://google/xxx?cloudSqlInstance=xxx:europe-west4:xxx&autoReconnect=true&user=xxx&password=xxx&socketFactory=com.google.cloud.sql.postgres.SocketFactory&useSSL=false


server.error.whitelabel.enabled=false

# Optimize start of application
spring.jmx.enabled=false

# Gcp configuration
spring.cloud.gcp.sql.enabled=false
spring.cloud.gcp.sql.database-name=xxx
spring.cloud.gcp.sql.instance-connection-name=xxx:europe-west4:xxx
spring.cloud.gcp.logging.enabled=true

編譯成功,沒有問題。 當我想訪問我的 Spring Boot 應用程序時出現問題。 我經常收到 502 錯誤。 日志中沒有任何內容可以讓我知道哪里出了問題:

A 2020-01-20T16:14:17Z   .   ____          _            __ _ _

A 2020-01-20T16:14:17Z  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \

A 2020-01-20T16:14:17Z ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \

A 2020-01-20T16:14:17Z  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )

A 2020-01-20T16:14:17Z   '  |____| .__|_| |_|_| |_\__, | / / / /

A 2020-01-20T16:14:17Z  =========|_|==============|___/=/_/_/_/

A 2020-01-20T16:14:17Z  :: Spring Boot ::        (v2.1.5.RELEASE)


com.xxx.api.xxxApplication       : Starting xxxApplication v0.0.1-SNAPSHOT on bc233766746a with PID 1 (/app.jar started by root in /)

com.xxx.api.xxxApplication       : The following profiles are active: gcp

 .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.

.s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 532ms. Found 17 repository interfaces.

 trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$2c4dbf14] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$c4fb874e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

 trationDelegate$BeanPostProcessorChecker : Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

 trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@6b00f608' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

 trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$e9d02a00] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

 trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

 trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$abce0c46] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)

o.apache.catalina.core.StandardService   : Starting service [Tomcat]

org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.19]

o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
 o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 11326 ms

com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...

Connecting to Cloud SQL instance [xxx:europe-west4:xxx] via SSL socket.

First Cloud SQL connection, generating RSA key pair.

這是我在日志中的最后幾行。 據我所知,似乎沒有任何問題,也沒有錯誤。 它似乎正確連接到 Cloud SQL 實例。 我在這里迷路了。 我已經嘗試了很多東西,但無論如何我總是從 Spring Boot 收到 502 請求。

有關信息,即使服務器未啟動, /liveness_check/readiness_check也總是返回 200(這很奇怪......)。

如果您需要有關我正在使用的配置的更多信息,請告訴我。 先感謝您!

我們終於解決了我們的問題。 對於那些可能有同樣問題的人:

問題是由我們的番石榴版本引起的。 我們添加了 18.0 版本,這顯然是有問題的。 我們在 pom.xml 中添加了以下依賴項:

<dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>28.2-jre</version>
        </dependency>

問題解決了:)

哇,只是在這里發泄一下,但現在已經嘗試將 spring 啟動應用程序部署到谷歌雲,這已經使我的頭發緊張了大約 2 周。 聽到修改 guava 依賴項可能導致應用程序無法啟動,這真是令人難以置信的神經緊張 - 更糟糕的是讓日志 go 保持沉默,沒有任何痕跡。 目前,我也在處理這樣一種情況,即沒有找到應用程序日志,也沒有任何問題的蹤跡,而只是在谷歌雲告訴我部署成功后簡單地嘗試訪問端點。

這個評論,我肯定會在未來寫其他人,更多的目的是讓其他人發泄他們的挫敗感,因為谷歌雲支持是不存在的,除非你支付額外費用。 更糟糕的是,就允許開發人員在部署不起作用時了解實際出了什么問題而言,該產品似乎非常糟糕。 我希望這能引起他們的注意,我希望其他人也能表達他們的沮喪,因為當這個產品沒有給出部署出現問題的跡象時,它根本無法使用。 我已經搜索了他們的文檔無濟於事,似乎其他人也有類似的問題。 不幸的是,我的手被我的客戶束縛了使用谷歌雲,否則我會在親眼看到它的一些非常基本的方式存在缺陷后離開它。 如果您正在評估雲產品,我強烈建議您不要使用谷歌。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM