【问题标题】:Spring Boot 2.5.5, CXF 3.4.5, Actuator - Missing actuator endpointsSpring Boot 2.5.5、CXF 3.4.5、Actuator - 缺少执行器端点
【发布时间】:2021-12-02 12:57:20
【问题描述】:

我正在使用 Spring Boot 2.5.5 和 CXF WS 3.4.5 创建一个微服务,它将在云上。要求之一是具有致动器。监控服务会定期检查微服务是否可用。

我有以下代码来发布端点

         @Bean
         public EndpointImpl endpoint() {
              EndpointImpl endpoint = new EndpointImpl(bus, serviceName);
              endpoint.getInInterceptors().add(wSS4JInInterceptor());
              endpoint.getInInterceptors().add(loggingInInterceptor);
              endpoint.getOutInterceptors().add(loggingOutInterceptor);
              endpoint.setBindingUri(SOAP12HTTP_BINDING);
              endpoint.publish("/servicename-service");
              return endpoint;
         }

WSDL 可通过以下方式访问 localhost:8082/service/servicename-service?wsdl

但是,localhost:8082/actuator 返回 Whitelabel 错误页面 (404 Not Found)。我尝试了这个网站和其他网站的许多解决方案,但都没有奏效。

我添加了以下代码,但没有帮助

    @Bean
    public ServletRegistrationBean cxfServlet() {
        return new ServletRegistrationBean(new CXFServlet(), "/service/*");
    }

我也尝试过覆盖 dispatcherServlet,但也没有用。

    @Bean
    public DispatcherServlet dispatcherServlet() {
        return new DispatcherServlet();
    }

    @Bean
    public ServletRegistrationBean dispatcherServletRegistrationBean() {
        ServletRegistrationBean dispatcherServlet = new ServletRegistrationBean(dispatcherServlet(), "/*");
        dispatcherServlet.setOrder(2);
        dispatcherServlet.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
        return dispatcherServlet;
    }

【问题讨论】:

    标签: spring-boot cxf spring-boot-actuator


    【解决方案1】:

    我不知道在此过程中发生了什么失败,但它现在可以正常工作。 这些步骤有所帮助:

    1. 从依赖项中移除 spring-boot-starter-actuator
    2. mvn 全新安装
    3. 重建项目
    4. 再次将 spring-boot-starter-actuator 添加到依赖项
    5. mvn 全新安装
    6. 启动项目并查看执行器和 wsdl 是否正常工作

    我什至删除了 cxfServlet 并在 application.yml 中设置 cxf.path=/service 以与当前功能保持一致。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-01
      • 2020-09-15
      • 2016-09-07
      • 2021-04-24
      • 2018-12-06
      • 1970-01-01
      • 2022-10-22
      • 2020-06-01
      相关资源
      最近更新 更多