Reputation: 361
I have an application, when I deployed to GCP, it failed to start but it was running all good in my local with docker. I have no idea how to resolve this, do I need to include anything in my properties file?
***************************
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.
I've included the properties as below
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
Inside my pom I've also included these
<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>
Anyone can help?
Upvotes: 0
Views: 3419
Reputation: 466
The most likely reason for GcpContextAutoConfiguration
to be excluded is that your deployed properties have spring.cloud.gcp.core.enabled=false
somewhere.
To check exactly what Spring Boot autoconfigures and why, pass -Ddebug=true
to your Java process (if running from Maven, pass it as -Dspring-boot.run.jvmArguments="-Ddebug=true"
.
Upvotes: 1
Reputation: 813
Try adding the Spring Cloud GCP starter to your dependencies that configures the authentication and project settings:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter</artifactId>
</dependency>
Also, if you specify the spring-cloud-gcp-starter-pubsub
dependency, it is not necessary to add the spring-cloud-gcp-pubsub
, as it is already included in the first one.
Upvotes: 0