在运行spring-boot应用程序期间, Bootstrap 属性未拾取,显示错误

mo49yndu  于 2023-06-21  发布在  Spring
关注(0)|答案(1)|浏览(157)

每当我尝试运行包含www.example.com的spring-boot应用程序bootstrap.properties,它都会显示此错误。但只要我把跳马设为假,它就能正常工作

Failed to bind properties under 'spring.cloud.vault.kv' to org.springframework.cloud.vault.config.VaultKeyValueBackendProperties:

似乎我的应用程序无法从 Bootstrap 拾取属性?

Bootstrap.properties

# Vault Configuration
spring.cloud.vault.enabled=${VAULT_ENABLE:true}
spring.cloud.vault.fail-fast=false
spring.cloud.vault.token=${VAULT_TOKEN}
spring.cloud.vault.scheme=${VAULT_SCHEME:http}
spring.cloud.vault.host=${VAULT_HOST:localhost}
spring.cloud.vault.port=${VAULT_PORT:8200}
spring.cloud.vault.generic.backend=secret/config
spring.cloud.vault.generic.application-name=${VAULT_CONFIG:order-api}
#Consul Configuration
spring.cloud.consul.enabled=${CONSUL_ENABLE:true}
spring.cloud.consul.host=${CONSUL_HOST:localhost}
spring.cloud.consul.port=${CONSUL_PORT:8500}
spring.cloud.consul.config.fail-fast=true
spring.cloud.consul.discovery.fail-fast=true
spring.cloud.consul.config.format=properties
spring.cloud.consul.config.prefix=config
spring.cloud.consul.config.name=${CONSUL_CONFIG}
spring.cloud.consul.config.acl-token=${CONSUL_ACL_TOKEN:}
spring.cloud.consul.config.watch.wait-time=${CONSUL_QUERY_DELAY:55}
spring.cloud.consul.config.data-key=application.properties
# Feign Configuration
feign.hystrix.enabled=true
# Disabled Consul Health Check
management.health.consul.enabled=false
spring.cloud.discovery.client.composite-indicator.enabled=false

Pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <parent>
    <groupId>com.gdn.partners</groupId>
    <artifactId>order-api</artifactId>
    <version>2.0.0-1-SNAPSHOT</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>order-app</artifactId>

  <dependencies>
    <dependency>
      <groupId>com.gdn.partners</groupId>
      <artifactId>order-web</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>com.gdn.partners</groupId>
      <artifactId>order-streaming</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>com.gdn.partners</groupId>
      <artifactId>order-common-utility</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-bootstrap</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-consul-config</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-consul-discovery</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-vault-config</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-openfeign</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-netflix-hystrix-dashboard</artifactId>
    </dependency>
  </dependencies>

  <build>
    <finalName>${project.name}</finalName>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <executable>true</executable>
          <mainClass>com.gdn.partners.order.OrderApiApplication</mainClass>
        </configuration>
      </plugin>
    </plugins>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
      <resource>
        <filtering>true</filtering>
        <directory>src/main/resources/public</directory>
        <includes>
          <include>version</include>
        </includes>
      </resource>
    </resources>
  </build>

</project>

更改了依赖项,因为我认为这可能是依赖项不匹配。

67up9zun

67up9zun1#

根据您提供的信息,我假设您错过了为应用程序添加一些spring.cloud.vault.kv属性。看看这篇博客,它可能会帮助你:https://medium.com/geekculture/configuring-vault-with-spring-boot-100889961b50

相关问题