Spring Boot第三方库 之 JavaMelody

本文的示例代码参考JavaMelodyDemo

JavaMelody

spring --version
# Spring CLI v2.0.6.RELEASE

spring init -b 2.0.6.RELEASE -dweb --build gradle JavaMelodyDemo && cd JavaMelodyDemo
vim build.gradle
dependencies {
    compile group: 'net.bull.javamelody', name: 'javamelody-spring-boot-starter', version: '1.78.0'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
vim application.properties
# server.port=7777
# javamelody.init-parameters.authorized-users=admin:123456
# javamelody.init-parameters.monitoring-path=/monitor
vim src/main/java/com/example/ApolloDemo/DemoApplication.java
package com.example.JavaMelodyDemo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @GetMapping("/test")
    public String test() {
        return "test";
    }

}
./gradlew bootrun

curl localhost:7777/test
  • 浏览器打开http://localhost:7777/monitor

Reference

  • APM应用性能监控管理开源工具收集

  • Spring Boot项目实战(三)集成Swagger及JavaMelody

  • 记JavaMelody间接导致线上服务占用内存过高的问题排查过程

你可能感兴趣的:(Spring Boot第三方库 之 JavaMelody)