提供management.port和management.context-path时,执行器不工作

时间:2019-01-04 13:26:13

标签: spring-boot spring-boot-actuator

我在应用程序属性中为Spring Boot执行器添加了不同的端口和上下文路径,但访问时得到以下响应

  

localhost: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

1 个答案:

答案 0 :(得分:0)

问题解决了。该异常源自实现package swingDemo; import java.awt.Color; import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.SwingUtilities;; public class ScrollDemo1 extends JFrame{ public ScrollDemo1() { JLabel label = new JLabel(); label.setBounds(50,0,1000,100); label.setText("Do you want to have a coffee together?"); JButton button = new JButton("Of course!"); button.setBounds(10,60,150,50); button.addActionListener(e -> label.setText("Well, let's go!")); JButton button2 = new JButton("No,sorry."); button2.setBounds(170,60,150,50); button2.addActionListener(e -> label.setText("Well, let's go!")); JPanel panel = new JPanel(); panel.setBounds(10,10,10,10); panel.add(button2); panel.add(button); panel.add(label); panel.setLayout(null); JScrollPane scrollPane = new JScrollPane(panel); scrollPane.setViewportBorder(BorderFactory.createLineBorder(Color.red)); scrollPane.setPreferredSize(new Dimension(20,20)); add(scrollPane); scrollPane.setViewportView(panel); setBounds(10,10,40,60); setTitle("Dating Robot"); } public static void main(String[] args) { // TODO Auto-generated method stub SwingUtilities.invokeLater(() -> { ScrollDemo1 obj = new ScrollDemo1(); obj.setVisible(true); }); } } 的自定义OncePerRequestFilter。在该过滤器中,我通过执行RememberMeServices来清除OAuthContext-这导致了restTemplate.getOAuth2ClientContext().setAccessToken(null);。我已将此语句放在BeanCreationException块中,并且执行器现在工作正常。

相关问题