本文介紹了如何在Spring Boot獨(dú)立應(yīng)用程序中激活JMX監(jiān)控的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我看了幾乎所有的文檔,但幾乎不能抓住這個(gè)神秘的東西。
那么我的問題是我可以通過http jmx url使用我的獨(dú)立的Spring Boot應(yīng)用程序來監(jiān)控我的應(yīng)用程序的運(yùn)行狀況和其他指標(biāo)嗎?我是否需要為此配置其他內(nèi)容?
我已在啟動(dòng)應(yīng)用程序中添加了以下依賴項(xiàng)。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
</dependency>
我還在配置文件中配置了以下屬性。
management.endpoints.web.exposure.include=*
management.endpoints.jmx.unique-names=true
management.server.port=8080
management.server.ssl.enabled=false
當(dāng)我嘗試點(diǎn)擊URL:http://localhost:8080/actuator/jolokia/health時(shí),無法看到任何結(jié)果。
還嘗試添加如下所示的自定義終結(jié)點(diǎn),但不起作用。
@Endpoint(id="mypoint")
@Component
public class myPointEndPoint {
@ReadOperation
public String mypoint(){
return "Hello" ;
}
具有附加屬性
Management.endpoint t.mypoint t.Enabled=True
推薦答案
問題出在您嘗試調(diào)用的URL。
首先,使用http://localhost:8080/actuator/jolokia/list
檢索可能的MBean
查看Health mBean時(shí),必須提供唯一的名稱和操作(Op)。
在我的例子中,它看起來像:http://localhost:8080/actuator/jolokia/exec/org.springframework.boot:type=Endpoint,name=Health,identity=4200098/health
同時(shí)查看Jolokia文檔:https://jolokia.org/reference/html/index.html
這篇關(guān)于如何在Spring Boot獨(dú)立應(yīng)用程序中激活JMX監(jiān)控的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,