I created one @RestController class and trying to use /refresh actuator values from config server. /refresh actuatoris not working. I am getting below error. Spring boot version is 2.0.0-Release. I can not upgrade spring boot version.
http://localhost:8888/secondservice/admin/refresh
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Thu Jan 23 10:16:10 EST 2020
***There was an unexpected error (type=Method Not Allowed, status=405).
Request method 'GET' not supported***
Dependency:-
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
Foo.Class
@RefreshScope
@RestController
public class Foo {
@Value("${welcome.message}")
private String personName;
@RequestMapping(value ="/", produces = "application/json", method = RequestMethod.POST)
public String greet(){
return "hello " + "POST "+ personName;
}
}
bootstrap.yml
server:
port: 8888
spring:
application:
name: secondservice
cloud:
config:
uri: http://localhost:8890/configserverdemo
fail-fast: false
enabled: true
server:
bootstrap: true
management:
context-path: /admin
security:
enabled: false
endpoints:
web:
exposure:
include: "*"
endpoint:
refresh:
enabled: true
There was an unexpected error (type=Method Not Allowed, status=405). Request method 'GET' not supported
The above error means that HTTP GET is not supported on that particular endpoint.
To refresh the config from spring config server you need to make an HTTP POST request on http://localhost:8888/secondservice/admin/refresh
Below is from the Spring guide
You can invoke the refresh Actuator endpoint by sending an empty HTTP POST to the client’s refresh endpoint
To make the HTTP POST request, you can use any HTTP client, eg Postman or cURL. To use cURL, you can run the below command on a terminal
curl -X POST http://localhost:8888/secondservice/admin/refresh