I'm starting to mess with Spring Cloud Config. I have a client application that simply writes the content of the application.yml that I have in a git repository. That works correctly, I can change the value, refresh and update the changes.
The problem comes if instead of collecting the value of an application.yml I want to take it from another. In my case I have renamed the application.yml of the git repository that contains the values to client-prueba.yml.
In my client application I have in the bootstrap.yml:
spring:
application:
name: cliente-prueba
cloud:
config:
uri: http://localhost:8888
In the client's application.yml:
server:
port: 8080
management:
endpoints:
web:
exposure:
include: "*"
In my application.yml of my server application
server:
port: 8888
management:
endpoints:
web:
exposure:
include: "*"
In the bootstrap.yml of the server application:
spring:
application:
name: configserver
cloud:
config:
server:
git:
uri: http://clinker/scm/git/Config-Server
username: myuser
password: mypass
searchPaths: Config-Server
And finally my client-prueba.yml:
palabra: hola
The client's controller:
@RestController
@RefreshScope
public class GestionController {
@Value("${palabra}")
private String miPalabra;
@GetMapping("/palabras")
public ResponseEntity<?> palabras () {
return ResponseEntity.ok().body(miPalabra);
}
}
I do not know exactly what I'm doing wrong.
Thank you very much.
UPDATE:
For some reason, the exposed code now works. My next problem is that if in the client-test.yml of the git change
palabra: hola
for
spring:
profiles: desarrollo
palabra: hola
the configuration server does not recover the file. If I create a client-test.yml and a client-test-development.yml with word with different values (without the spring.profiles) it works correctly and returns the value I have depending on the profile, but, why can not I have several profiles in the same file?