Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to customize endpoints for SpringBoot2

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "how to customize the endpoint of SpringBoot2". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope this article of "how to customize the endpoint of SpringBoot2" can help you solve the problem.

SpringBoot2 new feature custom endpoint package com.yan.otlan.springboot; import org.springframework.boot.actuate.endpoint.annotation.Endpoint;import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;import org.springframework.boot.actuate.endpoint.annotation.Selector;import org.springframework.stereotype.Component; @ Endpoint (id = "customPoint") @ Componentpublic class StatusEndPoint {@ ReadOperation public String getCustom (@ Selector String name) {return "MyName is." + name }}

Only three annotations are needed: @ endpoint, @ ReadOperation, @ Selector

Start the springboot project

Seeing the red mapped shows that it can be successful.

Visit http://127.0.0.1:8080/actuator/customPoint/156

Result

SpringBoot-Actuator- Custom Endpoint Properties close all endpoints management.endpoints.enabled-by-default: false modify access project path

The default access path is / actuator, which can be modified by modifying the following properties

Management.endpoints.web.base-path: / actuator

For example, the default access path is http://ip:port/actuator

If you want to change access path to http://ip:port/myActuator

You can set the property to / myActuator

The path must start with /, otherwise it cannot be accessed

That's all for "how to customize endpoints for SpringBoot2". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report