如何让 Javamelody 使用不同的端口(Spring Boot+暴露的两个 HTTP 端口) [英] How to make Javamelody use different port (Spring Boot+two HTTP ports exposed)

查看:80
本文介绍了如何让 Javamelody 使用不同的端口(Spring Boot+暴露的两个 HTTP 端口)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 Spring Boot Web 应用程序.它在端口 8080 上公开 REST API.它还公开了带有 Spring Boot Management 端点的管理端口 8081 (http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-monitoring.html).我没有任何自定义 Tomcat 配置来实现这一点.我的 application.properties 文件中只有属性 management.port=8081.

I have Spring Boot web application. It exposes REST API on port 8080. It also exposes management port 8081 with Spring Boot Management endpoints (http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-monitoring.html). I do not have any custom Tomcat configuration to achieve that. I just have property management.port=8081 in my application.properties file.

我按照中所述配置了 JavaMelodyhttps://github.com/javamelody/javamelody/wiki/UserGuideAdvanced#spring-boot-app(我有我的自定义 JavaMelodyConfiguration 类,使用 org.springframework.boot.web.servlet.FilterRegistrationBean 注册 net.bull.javamelody.MonitoringFilter).

I have JavaMelody configured as described in https://github.com/javamelody/javamelody/wiki/UserGuideAdvanced#spring-boot-app (I have my custom JavaMelodyConfiguration class, with org.springframework.boot.web.servlet.FilterRegistrationBean that registers net.bull.javamelody.MonitoringFilter).

@Bean
    public FilterRegistrationBean javaMelody() {
        final FilterRegistrationBean javaMelody = new FilterRegistrationBean();
        javaMelody.setFilter(new MonitoringFilter());
        javaMelody.setAsyncSupported(true);
        javaMelody.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.ASYNC);
        javaMelody.addUrlPatterns("/*");
        return javaMelody;
    }

通过此配置,Javamelody 暴露在端口 8080(业务端口)上.我想把它移到 8081(管理端口).如何改变?

With this configuration, Javamelody is exposed on port 8080 (business port). I would like to move it to 8081(management port). How to change that?

我使用的是 Spring Boot 1.4.2.RELEASE,javamelody 1.62.0

I use Spring Boot 1.4.2.RELEASE, javamelody 1.62.0

推荐答案

如果目标是在管理端口上公开监控,从 java melody 1.76 版开始现在要简单得多.

If the goal is to expose monitoring on management port starting from java melody version 1.76 is now much simpler.

您需要 Spring Boot 2.x、执行器和 yml 或属性文件:

You need Spring Boot 2.x, actuator and in yml or properties file:

  • management.server.port:{您的自定义端口}
  • management.endpoints.web.exposure.include:{你通常想要什么},监控
  • javamelody.management-endpoint-monitoring-enabled: 真

在此处查看更多详细信息:https://github.com/javamelody/javamelody/wiki/SpringBootStarter#configuration-in-case-of-management-port

See more details here: https://github.com/javamelody/javamelody/wiki/SpringBootStarter#configuration-in-case-of-management-port

这篇关于如何让 Javamelody 使用不同的端口(Spring Boot+暴露的两个 HTTP 端口)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆