spring-boot - 提供 management.port 和 management.context-path 时执行器不工作
问题描述
我在我的应用程序属性中为弹簧启动执行器添加了不同的端口和上下文路径,但是当我访问时我得到以下响应
本地主机:9091/app/actuator/health
{
"payload": {
"timestamp": "2019-01-04T13:10:42Z",
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.beans.factory.BeanCreationException",
"message": "Error creating bean with name 'scopedTarget.oauth2ClientContext': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.",
"path": "/app/actuator/health"
}
}
这是我的配置
server:
port: 9090
contextPath: /app
...
management:
port: 9091
ssl.enabled: false
security:
roles: ACTUATOR_GET
context-path: /app/actuator
endpoints:
hypermedia:
enabled: true
...
我究竟做错了什么 ?
我正在使用 spring-boot 1.5
解决方案
问题解决了。异常源自OncePerRequestFilter
实施的自定义RememberMeServices
。在那个过滤器中,我OAuthContext
通过做来清除restTemplate.getOAuth2ClientContext().setAccessToken(null);
- 这是导致BeanCreationException
. 我已将此语句放在一个try-catch
块中,执行器现在工作正常。
推荐阅读
- c++ - 了解段错误信息
- java - GSON 反序列化自定义对象的映射
- sql - 在 bigquery 中循环查询
- azure-cognitive-search - search.in 函数没有返回正确的结果
- javascript - 与 HTML/JavaScript 中的 Element 属性保持一致
- flutter - 自定义 Flutter 小部件返回两个用于 CustomScrollView / slivers 的小部件
- c# - 用unicode编写的文字字符串和变量字符串有什么区别
- terraform - Azure APIM 更改虚拟网络类型 - 强制替换 [Terraform]
- javascript - 我需要一个 Promise 中的 Promise 及其 .then 先运行
- flutter - 防止文本在颤动中溢出