如何在没有 git 配置文件的情况下配置 Spring 云配置服务器?
How to configure Spring Cloud Configuration Server without the git profile?
我正在尝试 运行 Spring 云配置服务器,完成一本书中的示例(Manning 的 Spring Microservices in Action),但更新到最新版本:Java 17,spring-boot-starter-parent 2.6.1,带 Spring Cloud 2021.0.0-RC1。
每次尝试启动服务器时,我都会收到此错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you have set spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
我没有使用 git
配置文件。我尝试了两种不同的配置文件:native
(类路径上有配置文件)和 vault
(本地有 Hashicorp Vault 服务器 运行ning)。我的最新 /src/resources/bootstrap.yml
包含以下内容:
spring:
application:
name: config-server
profiles:
active: vault
cloud:
config:
server:
vault:
port: 8200
host: 127.0.0.1
kvVersion: 2
server:
port: 8071
我最好的猜测是 bootstrap.yml
文件在服务器启动时没有被获取,也许 git
配置文件是默认的。我该如何补救?
好的,看来这里的问题是 Spring 云配置服务器的较新版本默认情况下不查找 bootstrap.yml
文件。有几种不同的方法可以解决它。最简单的方法就是将所有属性移至 application.yml
/application.properties
。
另一种选择是(在 NEWBEDEV here 中找到)包括实现“遗留”bootstrap 行为的依赖项:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
我正在尝试 运行 Spring 云配置服务器,完成一本书中的示例(Manning 的 Spring Microservices in Action),但更新到最新版本:Java 17,spring-boot-starter-parent 2.6.1,带 Spring Cloud 2021.0.0-RC1。
每次尝试启动服务器时,我都会收到此错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you have set spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
我没有使用 git
配置文件。我尝试了两种不同的配置文件:native
(类路径上有配置文件)和 vault
(本地有 Hashicorp Vault 服务器 运行ning)。我的最新 /src/resources/bootstrap.yml
包含以下内容:
spring:
application:
name: config-server
profiles:
active: vault
cloud:
config:
server:
vault:
port: 8200
host: 127.0.0.1
kvVersion: 2
server:
port: 8071
我最好的猜测是 bootstrap.yml
文件在服务器启动时没有被获取,也许 git
配置文件是默认的。我该如何补救?
好的,看来这里的问题是 Spring 云配置服务器的较新版本默认情况下不查找 bootstrap.yml
文件。有几种不同的方法可以解决它。最简单的方法就是将所有属性移至 application.yml
/application.properties
。
另一种选择是(在 NEWBEDEV here 中找到)包括实现“遗留”bootstrap 行为的依赖项:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>