0

我有一个应用程序,当我部署到 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>

任何人都可以帮忙吗?

4

2 回答 2

1

被排除在外的最可能原因GcpContextAutoConfiguration是您部署的属性有spring.cloud.gcp.core.enabled=false某个地方。

要准确检查 Spring Boot 自动配置的内容和原因,请传递-Ddebug=true给您的 Java 进程(如果从 Maven 运行,请将其传递为-Dspring-boot.run.jvmArguments="-Ddebug=true".

于 2021-07-26T15:10:56.480 回答
0

尝试将 Spring Cloud GCP starter 添加到配置身份验证和项目设置的依赖项中:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-gcp-starter</artifactId>
</dependency>

此外,如果您指定spring-cloud-gcp-starter-pubsub依赖项,则无需添加spring-cloud-gcp-pubsub,因为它已包含在第一个中。

于 2021-07-14T11:05:05.080 回答