Привод не работает, если указан файл management.port и management.context-path - PullRequest
0 голосов
/ 04 января 2019

Я добавил другой порт и контекстный путь для привода с пружинной загрузкой в ​​свойствах моего приложения, но я получаю следующий ответ при доступе к

локальный: 9091 / приложение / привод / здоровье

{
    "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
...

Что я делаю не так?

Я использую пружинную загрузку 1.5

1 Ответ

0 голосов
/ 03 июля 2019

Проблема решена. Исключение возникло из пользовательского OncePerRequestFilter, который реализовал RememberMeServices. В этом фильтре я очищал OAuthContext, выполняя restTemplate.getOAuth2ClientContext().setAccessToken(null); - что вызывало BeanCreationException. Я поместил это утверждение в блок try-catch, и привод теперь работает нормально.

...