我使用带有 Spring boot 2.0.0.RELEASE 的 Spring cloud config Finchley.M8 版本。我注意到 /bus/refresh 已更改为 /bus-refresh。但是,每当我使用 post http 请求点击 url 时,它就无法正常工作。这是 application.properties 的片段:
spring.cloud.bus.enabled=true
management.endpoints.web.exposure.include=bus-refresh,refresh
management.endpoints.web.base-path=/
此外,我扩展了 WebSecurityConfigurerAdapter 以添加以下代码片段:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll();
}
这是我试图测试的网址:
post http://localhost:8000/bus-refresh?destination=**:dev
然后我收到以下错误消息
{
"timestamp": "2018-03-18T07:03:54.135+0000",
"status": 403,
"error": "Forbidden",
"message": "Forbidden",
"path": "/bus-refresh"
}
此外,这里是 pom.xml 中依赖项的片段:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.M8</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-amqp</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-properties-migrator</artifactId>
</dependency>
</dependencies>
请问有什么帮助吗?
注意:我使用的是带有 spring 1.5.6 的旧版本的 spring cloud,它工作正常,当我使用最新的 spring cloud 版本迁移到 Spring boot 2 时遇到了这个问题。