我遵循了来自spring.io的Spring cloud配置示例。正在尝试使用git从属性文件中读取属性。我尝试了Stackoverflow中给出的类似问题的建议,但它不起作用。有什么见解可以帮助解决这个问题吗?
顺便说一句,我使用的是Windows 10、JDK 8、Spring Boot 2.0.4
这是我在服务器端的配置。我尝试了git和native,但没有成功:
spring:
profiles:
active:
# - native
- development
---
spring:
profiles: native
cloud:
config:
server:
native:
search-locations:
- C:/config-repo
---
spring:
profiles: development
# using git
cloud:
config:
server:
git:
uri: file:///C:/config-repo
---
server:
port: 8888
config.properties file exists in C:\config-repo
contents of config.properties:
message = "Hello Spring Boot config"配置客户端配置:
public class SpringCloudconfigClientApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCloudconfigClientApplication.class, args);
}
}
@RefreshScope
@RestController
class MessageRestController {
@Value("${message:Hello default}")
private String message;
@RequestMapping("/message")
String getMessage() {
return this.message;
}
}https://stackoverflow.com/questions/51714987
复制相似问题