我有一个简单的 Spring Config Server 应用程序,它使用 GIT 存储库中的配置数据。此配置服务器在我的本地和开发环境中按预期完美运行。但是,一旦部署到生产服务器,我一直看到这个错误:org.springframework.cloud.config.server.environment.NoSuchLabelException: No such label: master
这是整个 JSON 返回:
{
"status": "DOWN",
"configServer": {
"status": "DOWN",
"repository": {
"application": "app",
"profiles": "default"
},
"error": "org.springframework.cloud.config.server.environment.NoSuchLabelException: No such label: master"
},
"discoveryComposite": {
"description": "Discovery Client not initialized",
"status": "UNKNOWN",
"discoveryClient": {
"description": "Discovery Client not initialized",
"status": "UNKNOWN"
}
},
"diskSpace": {
"status": "UP",
"total": 10434699264,
"free": 6599856128,
"threshold": 10485760
},
"refreshScope": {
"status": "UP"
},
"hystrix": {
"status": "UP"
}
}
所以我将它追溯到 spring-cloud-config GitHub repo,并看到它被扔在这里:https ://github.com/spring-cloud/spring-cloud-config/blob/b7afa2bb641913b89e32ae258bd6ec442080b9e6/spring-cloud- config-server/src/main/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepository.java#185 当找不到 Git 分支时,GitCommand 类的 call() 方法在第 235 行抛出此错误。但我一生都无法理解为什么!!!我已经仔细检查并验证了配置属性的 GIT 存储库中确实存在“master”分支。
配置服务器的应用程序属性在 bootstrap.yml 文件中定义,如下所示:
server:
port: 8080
management:
context-path: /admin
endpoints:
enabled: false
health:
enabled: true
logging:
level:
com.netflix.discovery: 'OFF'
org.springframework.cloud: 'DEBUG'
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
statusPageUrlPath: /admin/info
healthCheckUrlPath: /admin/health
spring:
application:
name: config-service
cloud:
config:
enabled: false
failFast: true
server:
git:
uri: 'https://some-spring-config-repo.git'
username: 'fakeuser'
password: 'fakepass'
basedir: "${catalina.home}/target/config"`
非常感激任何的帮助!!