当前位置: 首页 > 知识库问答 >
问题:

CXF和Spring引导执行器,执行器endpoint不可用

曹臻
2023-03-14

我有一个使用spring Boot1.4.2和CXF JAXR的项目设置。我想把Spring引导执行器添加到项目中。这是我添加到项目中的配置。

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

在此之后创建一个WAR文件,然后将其部署在外部tomcat服务器中。但是当我访问健康URL localhost:8080/management/health时,它给出的是404 HTTPhtml" target="_blank">代码。服务器正常启动,我可以看到包含以下详细信息的日志:

运行状况配置日志

[localhost-startStop-1]INFO org.springframework.boot.actuate.endpoint.mvc.endpointHandlermapping-将“{[/management/health/management/health.json],produces=[application/json]}”映射到公共java.lang.object

Servlet配置日志

[localhost-startStop-1]INFO org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean-映射筛选器:“Spring SecurityFilterChain”到:[/*]

[localhost-startStop-1]INFO org.springframework.boot.web.servlet.FilterRegistrationBean-将筛选器:“Web RequestLoggingFilter”映射到:[/*]

[localhost-startStop-1]INFO org.springframework.boot.web.servlet.FilterRegistrationBean-将筛选器:“Application ContextIDFilter”映射到:[/*]

[localhost-startStop-1]INFO org.springframework.boot.web.servlet.ServletRegistrationBean-将servlet:“dispatcher servletRegistration”映射到[]

[localhost-startStop-1]INFO org.springframework.boot.web.servlet.ServletRegistrationBean-将servlet:“dispatcher servlet”映射到[/]

[localhost-startStop-1]INFO org.springframework.boot.web.servlet.ServletRegistrationBean-将servlet:“CXFServlet”映射到[/services/*]

共有1个答案

堵德曜
2023-03-14

问题解决了,这里是细节。由于CXF和spring boot一起被合并,所以CXF REST API和执行器endpoint都被配置为“/”。为CXF REStendpoint配置的servlet bean的名称是DispatcherServletRegistration。还有一个问题是,CXF servlet的自动配置也在发生,因为POM中有CXF的引导启动程序。因此,您可以发现CXFServlet也为/services/*配置。

将servlet:“Dispatcher ServletRegistration”映射到[]

将servlet:“dispatcher servlet”映射到[/]

将servlet:“CXFServlet”映射到[/services/*]

我删除了auto configuration option(CXFServlet),因为CXF JAXRS实现需要一些定制,并将dispatcherServletRegistration映射到/services/*,现在一切都正常工作。现在执行器在'/'下工作,CXF REST API在/services下工作。

 类似资料:
  • 访问类似http://localhost:6061/health的endpointhttp://localhost:6061/env 这里是我的gradle构建文件的部分

  • {“Status”:“Down”} 我需要做什么才能显示自定义健康状况指示器?

  • Spring Boot执行器的两个版本(1.2.5和1.3.0)在HealthMvcEndpoint,isUnrestricted()方法(&&and)中的实现存在差异。我明白这是为了保留这些限制 http://docs.spring.io/spring-boot/docs/current-snapshot/reference/htmlsingle/#production-ready-health

  • 控制台输出: 我试图访问http://localhost:8080/acturet/health的执行器健康endpoint,但没有成功。

  • 我第一次使用Spring Boot应用程序时,执行器是不安全的,所以很容易通过/acture/shutdownendpoint远程关闭。最近,我已经使用Spring安全保护了我的执行器,它已经起作用了。现在我需要提供http基本凭据来访问endpoint,但现在对/acture/shutdownendpoint的curl调用失败,出现禁止错误。我一定是配置不正确的地方。 我的卷曲命令: 我的配置: