我有一个使用cxf和spring boot的应用程序。所有工作都由基于cxf的servlet完成。但是,还有另一个默认的servlet进行了初始化,以为负载均衡器提供ping.html。 AFAIK,该servlet初始化并获取默认上下文作为应用程序jar名称。因此应该可以通过
访问http://serverAddress:port/myApp/ping.html
但是,当我尝试访问ping.html时,它位于以下网址:
http://serverAddress:port/ping.html
我无法弄清为什么路径中缺少应用程序上下文(myApp)。我需要做的是使该页面可以通过(myApp / ping.html)进行访问
这是我的Servlet初始化代码:
@Bean
public ServletRegistrationBean cxfServlet() {
final ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new CXFServlet(), "/*");
servletRegistrationBean.setLoadOnStartup(1);
return servletRegistrationBean;
}
@Bean
public ServletRegistrationBean healthCheckServletBean() {
ServletRegistrationBean pingHealthCheckServletBean = new ServletRegistrationBean(new DefaultServlet(), "/ping.html");
pingHealthCheckServletBean.setLoadOnStartup(1);
return pingHealthCheckServletBean;
}
@Bean(destroyMethod = "destroy")
@DependsOn("cxf")
public Server myCxfServer(SpringBus cxf) {
final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
factory.setServiceBean(myService);
factory.setProvider(new JacksonJsonProvider());
factory.setBus(cxf);
factory.setExtensionMappings(extentionMappings());
return factory.create();
}
@Bean(destroyMethod = "shutdown")
public SpringBus cxf() {
return new SpringBus();
}