You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用actuator/bus-refresh端点报错:POST方法不被支持

问题排查:POST请求/actuator/bus-refresh返回405 Method Not Allowed

向http://localhost:8888/actuator/bus-refresh发送POST请求时,返回如下错误:

{"timestamp": 1663260534141,"status": 405,"error": "Method Not Allowed","exception": "org.springframework.web.HttpRequestMethodNotSupportedException","message": "Request method 'POST' not supported","path": "/actuator/bus-refresh"}

相关配置信息

服务端依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

客户端依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.6.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.springbus.client</groupId>
<artifactId>spring_bus</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring_bus_client</name>
<description>spring_bus_client</description>
<properties>
    <java.version>1.8</java.version>
    <spring-cloud.version>2021.0.4</spring-cloud.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bus-amqp</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</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>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Dalston.SR2</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
</project>

客户端应用属性

spring.config.import=configserver:http://localhost:8888
management.security.enabled=false
management.endpoints.web.exposure.include=bus-refresh
spring.cloud.bus.enabled=true
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

服务端应用属性

spring.cloud.config.server.git.uri=/home/jj/Spring_Bus/configrepo
server.port=8888
spring.cloud.bus.enabled=true
management.endpoints.web.exposure.include=bus-refresh
spring.cloud.config.enabled=false
#spring.cloud.config.profiles=native
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

排查与解决

1. 修复版本兼容性冲突

客户端存在严重版本不匹配问题:

  • Spring Boot父版本为1.5.6.RELEASE(对应Spring Cloud Dalston系列),但properties中指定了spring-cloud.version=2021.0.4(对应Spring Boot 2.6.x),dependencyManagement又导入了Dalston.SR2,三者完全不兼容。

解决:
统一版本体系:

  • 若保留Spring Boot 1.5.x,删除properties中的spring-cloud.version=2021.0.4,保持Dalston.SR2的依赖管理配置;
  • 若升级到新版本,将父版本改为2.6.11(与Spring Cloud 2021.0.4匹配),同步调整所有依赖适配新版本。

2. 调整Actuator端点配置

Spring Boot 1.x和2.x的Actuator配置差异极大:

  • 你当前用的是Spring Boot 2.x的配置(management.endpoints.web.exposure.include=bus-refresh),但客户端实际是1.5.x,导致配置失效,端点路径也不匹配(1.x中总线刷新端点为/bus/refresh,而非/actuator/bus-refresh)。

解决:
根据Spring Boot版本调整配置:

  • 若使用Spring Boot 1.5.x(客户端当前版本),修改客户端配置为:
    management.security.enabled=false
    endpoints.bus-refresh.enabled=true
    endpoints.bus-refresh.sensitive=false
    
    此时请求路径应为POST http://localhost:8888/bus/refresh;若服务端是Spring Boot 2.x,需确保服务端与客户端版本统一。

3. 修正服务端Config Server配置

服务端设置了spring.cloud.config.enabled=false,但依赖了spring-cloud-config-server,会导致Config Server功能失效,总线刷新依赖Config Server分发配置,进而引发端点异常。

解决:
删除spring.cloud.config.enabled=false配置项,确保Config Server正常启动。

4. 验证端点请求方式

发送GET请求到http://localhost:8888/actuator,查看返回的端点列表中bus-refresh的allowedMethods是否包含POST。若未包含,检查spring-cloud-starter-bus-amqp依赖是否正确引入且版本匹配。


内容的提问来源于stack exchange,提问作者Jai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 10:01:09