Spring Boot JavaMelody Tutorial

Tutorial describing how to integrate JavaMelody with Spring Boot 2 application to monitor application health.

Please note that this configuration isn’t compatible with Spring Boot 1 nor plain Spring project. For those project we cannot use the javamelody-spring-boot-starter library with preconfigured JavaMelody beans but should use the javamelody-core dependency and do the configuration ourself like desbribed here.

Technologies used:

  1. Spring Boot 2.2.1.RELEASE
  2. JDK 1.8
  3. Maven 3
  4. JavaMelody

Project setup

Project dependencies managed by the Maven’s pom.xml configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">







The explanation of above dependencies:

  • spring-boot-starter-web – packages all the necessary dependencies together with the auto configuration for running simple web application
  • javamelody-spring-boot-starter – provides auto configuration for JavaMelody
  • spring-boot-maven-plugin – plugin prividing commands to work with a Spring Boot application (we will be usine the spring-boot:run command)

Application Initializer

public class Application extends SpringBootServletInitializer {

    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);

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

We don’t have to configure anything for enabling JavaMelody. The javamelody-spring-boot-starter does all the job.


public class HelloWorldController {

public String hello() {
return "Hello World";


The project can be started by the running the following command:

mvn clean spring-boot:run

By visiting the localhost:8080/hellourl, we should see the page with “Hello World” text.

By visiting the localhost:8080/monitoringurl, we can see JavaMelody reports.

The example code you can download from here

Leave a Reply

Your email address will not be published. Required fields are marked *