Alw*_*mer 5 spring spring-boot configserver
我正在尝试在 Spring Boot 2.1.6 版本中创建嵌入式配置服务器。启动失败说:
***************************
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 are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
Run Code Online (Sandbox Code Playgroud)
我不确定 spring 是否清楚地记录了本机配置文件是什么,而我的 bootstrap.yml 如下所示:
---
spring:
application:
name : <name>
datasource:
url: <url>
driver-class-name: oracle.jdbc.OracleDriver
username: <username>
password: <password>
hikari:
maximum-pool-size: 1
connection-timeout: 5000
cloud:
config:
server:
bootstrap: true
default-label: latest
jdbc:
sql: <sql>
order: 0
jpa:
database: Oracle
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.Oracle10gDialect
profiles:
active:
- jdbc
- sit
Run Code Online (Sandbox Code Playgroud)
如果我在活动配置文件列表中添加“本机”,错误就会消失。
但我找不到 spring 文档,其中说,除 git 之外的任何配置服务器默认都是“本机”。
这是 spring 2.xx 版本中的新增内容,因为我只是从 1.5.10 版本升级,系统就崩溃了。
所以我的问题是:
这个本机配置文件是否从 spring 2.xx 版本开始强制执行,从而使其向后不兼容,或者有一个解决办法,通过它我可以跳过在我的活动配置文件列表中添加此本机配置文件。
参考:
https://cloud.spring.io/spring-cloud-config/2.1.x/multi/multi_spring-cloud-config.html
不确定我记得是否正确,但我认为这个问题是针对使用数据库支持的配置服务器配置时提出的。
解决方案:
在 src/main/resources 中,创建一个文件夹 meta-inf 并添加一个文件 spring.factories。在此文件中添加以下代码:
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration
Run Code Online (Sandbox Code Playgroud)
请告诉我这是否有效
| 归档时间: |
|
| 查看次数: |
1022 次 |
| 最近记录: |