【问题标题】:Spring boot restful management endpoint returns a HTTP/1.1 400 Bad RequestSpring boot RESTful 管理端点返回 HTTP/1.1 400 Bad Request
【发布时间】:2014-04-07 15:48:54
【问题描述】:

我正在尝试使用具有以下 URL 的浏览器访问 Spring Boot管理端点之一:http://localhost:9080/env

这是我的配置

management.port: 9080
management.address: 127.0.0.1

我总是收到 400 bad request 错误...

这是完整的输出

Request URL:http://localhost:9080/env
Request Method:GET
Status Code:400 Bad Request

Request Headers
GET /env HTTP/1.1
Host: localhost:9080
Connection: keep-alive
Cache-Control: max-age=0
Authorization: Basic dXNlcjo0YWI0ZDRjMi1mYmIyLTQxYmYtODc0MS04YTk3YWQwZDE3ZWI=
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: fr-FR,fr;q=0.8,en;q=0.6,es;q=0.4,en-GB;q=0.2
Cookie: JSESSIONID=0A00A8C2431F58BF6CD3A9F12822820C

Response Headers
HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 968
Date: Wed, 05 Mar 2014 14:09:13 GMT
Connection: close

有人可以帮忙吗?

【问题讨论】:

    标签: spring-boot


    【解决方案1】:

    我找到了问题的答案:

    为了获得宁静的管理端点需要 Spring Boot Actuator

    任何使用带有 Actuator 的 Spring Boot 的应用程序都启用了这些 restful 管理端点。

    编辑:必要的 Maven 依赖:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    

    【讨论】:

    • /env端点确实是Actuator自带的。但这并不能解释 400(如果端点不存在,我希望 404)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-01
    • 1970-01-01
    • 2013-01-29
    相关资源
    最近更新 更多