java - Spring 云服务器返回空配置
问题描述
我有一个简单的配置服务器,具有以下属性:
spring:
profiles:
active: native
cloud:
config:
server:
native:
searchLocations: classpath:/configs
server:
port: 8888
在 src/main/resources 文件夹中,我有一个 configs 文件夹,其中包含一个 customer-service.yml 文件,其中包含以下配置:
spring:
application:
name: customer-service
h2:
console:
enabled: true
server:
port: 8080
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
instance:
preferIpAddress: true
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
logging:
level:
com.netflix: WARN
配置服务器启动没有问题,但在浏览器中发出以下 URL - http://localhost:8888/customer-service/master - 返回以下响应:
{"name":"customer-service","profiles":["master"],"label":null,"version":null,"state":null,"propertySources":[]}
似乎没有很多使用类路径上的文件夹来存储配置的示例。我究竟做错了什么?
解决方案
我刚刚使用 Spring 2.1.3 进行了尝试,它可以按照您的说明工作。由于您提到您使用的是 Spring 2.2,因此可能存在更改或潜在的错误。
更新
只是为了好玩,我用 2.2.0.BUILD-SNAPSHOT 试了一下,效果也很好。不知道此时该说什么。
推荐阅读
- reactjs - 如何使用带有端口的 reactjs 在 laravel 中处理 CORS 问题
- r - R: ERROR - rep.int(c(1, numeric(n)), n - 1L) 中的错误:'times' 值无效
- javascript - 使用 javascript (docx-js) 修改 .docx TOC 的“样式”
- sql - SQL Server 2008 等效于“ROWS BETWEEN UNBOUNDED PRECEDING”
- typescript - 无法部署“pubsub”云功能
- flutter - 颤动:奇怪的颜色和字体大小
- php - 在实时服务器中找不到类,而在 localhost 中没有问题
- apache-spark - spark(2.3或新版本)如何确定读取gs bucket或hdfs中hive表文件的任务数?
- python - Azure TableService() 在 prod 中返回 python ValueError,但在 dev 中不返回
- ruby - 无法在 Windows 上安装 bcrypt 3.1.16 gem:ld.exe:找不到 -lgmp