Spring Boot第三方库 之 JavaMelody

2020-01-18  本文已影响0人  诺之林

本文的示例代码参考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

Reference

上一篇下一篇

猜你喜欢

热点阅读