我有一个应用程序,当我部署到GCP时,它无法启动,但它在我的本地docker中运行得很好。我不知道如何解决这个问题,我需要在我的属性文件中包含任何内容吗?
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 1 of constructor in org.springframework.cloud.gcp.autoconfigure.pubsub.GcpPubSubAutoConfiguration required a bean of type 'org.springframework.cloud.gcp.core.GcpProjectIdProvider' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
The following candidates were found but could not be injected:
- Bean method 'gcpProjectIdProvider' in 'GcpContextAutoConfiguration' not loaded because auto-configuration 'GcpContextAutoConfiguration' was excluded
- Bean method 'gcpProjectIdProvider' in 'GcpContextAutoConfiguration' not loaded because auto-configuration 'GcpContextAutoConfiguration' was excluded
- Bean method 'gcpProjectIdProvider' in 'GcpContextAutoConfiguration' not loaded because auto-configuration 'GcpContextAutoConfiguration' was excluded
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.cloud.gcp.core.GcpProjectIdProvider' in your configuration.
我已经包括了以下属性
spring.cloud.gcp.pubsub.enabled: true
spring.cloud.gcp.config.enabled: true
spring.cloud.gcp.security.iap.enabled: true
#I DO NOT have this line below
#spring.autoconfigure.exclude: org.springframework.cloud.gcp.autoconfigure.core.GcpContextAutoConfiguration
在我的pom中,我还包含了这些
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot-release.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>${spring-cloud-gcp.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-pubsub</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
</dependency>
<dependencies>
有人能帮忙吗?
GcpContextAutoConfiguration
被排除的最可能原因是您部署的属性在某个地方有spring.cloud.gcp.core.enabled=false
。
要检查Spring Boot自动配置的内容以及原因,请将-Ddebug=true
传递给Java进程(如果从Maven运行,请将其传递为-Dspring-boot.run.jvmArguments="-Ddebug=true"
.
尝试将Spring Cloud GCP启动器添加到配置身份验证和项目设置的依赖项中:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter</artifactId>
</dependency>
此外,如果指定spring-cloud-gcp-starter-pubsub
依赖项,则无需添加spring-cloud-gcp-pubsub
,因为它已包含在第一个依赖项中。