SpringBoot中Jersey与Actuator遇到的路径问题

Jersey中集成actuator

Spring Boot 官方Reference中描述如下:

80.3 Actuator and Jersey

Actuator HTTP endpoints are only available for Spring MVC-based applications. If you want to use Jersey and still use the actuator you will need to enable Spring MVC (by depending on spring-boot-starter-web, for example). By default, both Jersey and the Spring MVC dispatcher servlet are mapped to the same path (/). You will need to change the path for one of them (by configuring server.servlet.path for Spring MVC or spring.jersey.application-path for Jersey). For example, if you add server.servlet.path=/system into application.properties, the actuator HTTP endpoints will be available under /system.

此处文档有误。添加属性server.servlet.path=/system,输出为

2017-05-18 15:07:55.741  INFO 18376 --- [           main] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'com.hitec.surfservice.config.JerseyConfig' to [/*]
2017-05-18 15:07:55.745  INFO 18376 --- [           main] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]

可见dispatcherServlet仍然映射至/,也就是说配置没有起作用。很快,在github上查找到了使用server.servletPath属性代替,即可满足要求,输出如下。

2017-05-18 15:07:55.741  INFO 18376 --- [           main] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'com.hitec.surfservice.config.JerseyConfig' to [/*]
2017-05-18 15:07:55.745  INFO 18376 --- [           main] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/system/*]
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容