I am following the Spring cloud config sample from spring.io. Trying to read a property from properties file by using git. I tried the suggestions given in Stackoverflow for similar questions but it did not work. Any insights to help solve this issue?
BTW, I am using Windows 10, JDK 8, Spring Boot 2.0.4
This is my config in server side. I tried with both git and native but no luck:
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"
Config Client configuration:
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;
}
}
I figured the client application name should match the properties file name. I am not sure if this is a requirement to have the file name matching with properties/yml file in config server.
Client side bootstrap.yml:
application.yml:
Config Server application.yml: