简体   繁体   English

无法让 Spring 引导应用程序在 Google Cloud Platform Flexible Environment 上工作

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

I'm having trouble deploying my Spring Boot application on the Google Cloud Platform Flexible environment.我在 Google Cloud Platform Flexible 环境中部署我的 Spring Boot 应用程序时遇到问题。

I run the following command to deploy: mvn clean compile package -DskipTests appengine:deploy -P cloud-gcp我运行以下命令进行部署: mvn clean compile package -DskipTests appengine:deploy -P cloud-gcp

The cloud-gcp profile in my pom.xml has the following:我的 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>

This is my app.yaml file located at src/main/appengine/app.yaml :这是我的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

Here is my application-gcp.properties :这是我的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

The compilation is successful, no problems there.编译成功,没有问题。 The problem occurs when I want to access my Spring Boot application.当我想访问我的 Spring Boot 应用程序时出现问题。 I constantly get a 502 Error.我经常收到 502 错误。 There is nothing in the logs that gives me a clue on what is wrong:日志中没有任何内容可以让我知道哪里出了问题:

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.

This is the last lines I have in the logs.这是我在日志中的最后几行。 Nothing seems to break, no errors as far as I can tell.据我所知,似乎没有任何问题,也没有错误。 It seems to correctly connect to the Cloud SQL instance.它似乎正确连接到 Cloud SQL 实例。 I'm lost here.我在这里迷路了。 I've tried a lot of things, but I always get a 502 request from Spring Boot no matter what.我已经尝试了很多东西,但无论如何我总是从 Spring Boot 收到 502 请求。

For information, the /liveness_check and /readiness_check always return 200 even when the server is not launched (which is strange...).有关信息,即使服务器未启动, /liveness_check/readiness_check也总是返回 200(这很奇怪......)。

Tell me if you need any more informations on the configuration I am using.如果您需要有关我正在使用的配置的更多信息,请告诉我。 Thank you in advance!先感谢您!

We finally solved our issue.我们终于解决了我们的问题。 For those who might have the same issue:对于那些可能有同样问题的人:

The problem was caused by our guava version.问题是由我们的番石榴版本引起的。 We add the version 18.0, which was problematic apparently.我们添加了 18.0 版本,这显然是有问题的。 We added the following dependencies in the pom.xml:我们在 pom.xml 中添加了以下依赖项:

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

And the problem was solved :)问题解决了:)

Wow, just doing some venting here but have been pulling my hair out for about 2 weeks now attempting to deploy a spring boot app to google cloud.哇,只是在这里发泄一下,但现在已经尝试将 spring 启动应用程序部署到谷歌云,这已经使我的头发紧张了大约 2 周。 It's incredibly nerve wracking to hear that a modification of a guava dependency could cause an application to not startup - even far worse make the logs go silent with no trace of what is going on.听到修改 guava 依赖项可能导致应用程序无法启动,这真是令人难以置信的神经紧张 - 更糟糕的是让日志 go 保持沉默,没有任何痕迹。 At the moment, I too am dealing with a situation where there are no application logs to be found and no trace of what is going wrong while just simply trying to hit an endpoint after what google cloud tells me is a successful deploy.目前,我也在处理这样一种情况,即没有找到应用程序日志,也没有任何问题的踪迹,而只是在谷歌云告诉我部署成功后简单地尝试访问端点。

This comment and I'm sure to write others in the future is more aimed at getting other people to vent their frustration as google cloud support is non-existent unless you pay a premium for it.这个评论,我肯定会在未来写其他人,更多的目的是让其他人发泄他们的挫败感,因为谷歌云支持是不存在的,除非你支付额外费用。 Making matters worse the product appears to be just plain terrible in terms of allowing developers insights into what is actually going wrong when a deployment doesn't work.更糟糕的是,就允许开发人员在部署不起作用时了解实际出了什么问题而言,该产品似乎非常糟糕。 I hope this gets their attention and I hope others voice their frustration as well because this product is simply unusable when it gives no indication of what is going wrong with a deployment.我希望这能引起他们的注意,我希望其他人也能表达他们的沮丧,因为当这个产品没有给出部署出现问题的迹象时,它根本无法使用。 I've scoured their docs to no avail and it seems others have similar issues.我已经搜索了他们的文档无济于事,似乎其他人也有类似的问题。 Unfortunately my hands are tied by my client to use google cloud otherwise I would have migrated away from it after seeing first hand some of the very basic ways it is flawed.不幸的是,我的手被我的客户束缚了使用谷歌云,否则我会在亲眼看到它的一些非常基本的方式存在缺陷后离开它。 If you're in the process of evaluating a cloud product I would highly recommend not using google.如果您正在评估云产品,我强烈建议您不要使用谷歌。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Google Cloud Platform Java Flexible Environment下载应用程序 - How to download application from Google Cloud Platform Java Flexible Environment 谷歌云发布/订阅自动配置在 Spring Boot 应用程序中不起作用 - Google cloud pub/sub autoconfigure does not work in Spring boot application Google Cloud Platform - Cloud SQL 上 MySQL 的 Spring Boot 应用程序连接问题 - Google Cloud Platform - Spring Boot application connection issues with MySQL on Cloud SQL 在Spring Boot上环境变量和@Value不能一起使用 - Environment variables and @Value can't work together on Spring Boot 如果我们已在Google Cloud Platform中部署Spring Boot应用程序,如何查看日志? - How to see the logs if we have deployed our Spring Boot Application in Google Cloud Platform? 使用环境变量打包后无法运行 Spring 引导应用程序 - Can't run Spring Boot application after packaging it with Environment Variables 使用 Spring Boot 2.2+,当应用程序不在云平台上运行时,如何创建 bean - With Spring Boot 2.2+, how can you create a bean when the application is NOT running on a Cloud Platform Angular2前端在Google云平台上的Spring Boot后端 - Angular2 frontend Spring Boot backend on Google cloud platform 不稳定的 Google Cloud Engine - 标准环境 - 延迟(Spring Boot 应用程序) - Erratic Google Cloud Engine - Standard Environment - Latency (Spring Boot App) Google Cloud Platform管道/容器构建器在Spring Boot Java Application中使用COPY或ADD命令构建docker映像时出现问题 - Google Cloud Platform pipeline/container builder issue building docker image using COPY or ADD command for Spring Boot Java Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM