In my casual spring boot application I regiser servlet like this.
import io.prometheus.client.exporter.*
.....
@Bean
public ServletRegistrationBean<MetricsServlet> registerMetricsServlet(MetricRegistry metricRegistry) {
return new ServletRegistrationBean<>(new MetricsServlet(), "/metrics");
}
This servlet is registred on the same port as application. The issue is that my infrastructure(k8s and etc) is expecting that application and metrics endpoint works on a different ports(like actuator does).
How can I register third party servlet on a ddifferent port ?
You can do it with multiple connectors and request filter. (All connectors are handle same way)
pay attention to the lines from
public FilterRegistrationBean javaMelodyRestrictingFilter(FilterRegistrationBean javaMelodyFilter) {...
Original answer here. Configure Spring Boot with two ports
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.