Spring boot 访问/刷新执行器不工作时出现意外错误(类型=方法不允许,状态=405)
我创建了一个@RestController类,并尝试从配置服务器使用/刷新执行器值。 /刷新执行器不工作。我正在犯错误。Spring启动版本是2.0.0版本。我无法升级spring启动版本 依赖关系:-Spring boot 访问/刷新执行器不工作时出现意外错误(类型=方法不允许,状态=405),spring-boot,spring-cloud,Spring Boot,Spring Cloud,我创建了一个@RestController类,并尝试从配置服务器使用/刷新执行器值。 /刷新执行器不工作。我正在犯错误。Spring启动版本是2.0.0版本。我无法升级spring启动版本 依赖关系:- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</a
<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>
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
出现意外错误(类型=方法不允许,状态=405)。
不支持请求方法“GET”
上述错误意味着该特定端点不支持httpget
要从spring配置服务器刷新配置,您需要在http://localhost:8888/secondservice/admin/refresh
下面是从春天来的
您可以通过向客户端的刷新端点发送空HTTP POST来调用刷新执行器端点
要发出HTTP POST请求,您可以使用任何HTTP客户端,例如或。要使用cURL,可以在终端上运行以下命令
curl -X POST http://localhost:8888/secondservice/admin/refresh
我已经在@RequestMapping上使用了“RequestMethod.POST”。如何发出HTTP Post请求?@user84您添加的
RequestMethod.Post
位于greet()
方法中,用于该特定端点,而不是刷新配置。刷新端点由Spring添加,POST请求可以使用任何http客户端进行。您甚至可以在终端上使用curl,比如curl-xposthttp://localhost:8888/secondservice/admin/refresh
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
curl -X POST http://localhost:8888/secondservice/admin/refresh