最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

spring監(jiān)視器actuator配置應(yīng)用

 更新時間:2023年07月08日 09:31:56   作者:back2childhood  
這篇文章主要介紹了spring監(jiān)視器actuator配置應(yīng)用,本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

引入依賴

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
    <version>3.1.0</version>
</dependency>

配置

# actuator
# 將所有路徑都加入監(jiān)視
management.endpoints.web.exposure.include=*
# 將某幾個路徑取消監(jiān)控
management.endpoints.web.exposure.exclude=info,caches

應(yīng)用

自帶的路徑

localhost:8080/mycommunity/actuator/health

在這里插入圖片描述

自定義路徑

@Component
@Endpoint(id = "database")
public class DatabaseEndpoint {
    private static final Logger logger = LoggerFactory.getLogger(DatabaseEndpoint.class);
    @Autowired
    private DataSource dataSource;
    // readOperation means this method can only be accessed by get request
    // writeOperation means this method can only be accessed by post request
    @ReadOperation
    public String checkConnection(){
        try(
                Connection connection = dataSource.getConnection();
           ) {
            return CommunityUtil.getJSONString(0,"success");
        } catch (SQLException e) {
            e.printStackTrace();
            logger.error("failed");
        }
        return CommunityUtil.getJSONString(1, "failed");
    }
}

訪問瀏覽器:localhost:8080/mycommunity/actuator/database

注意actuator路徑只能對管理員訪問,注意做權(quán)限管理

到此這篇關(guān)于spring監(jiān)視器actuator的文章就介紹到這了,更多相關(guān)spring監(jiān)視器內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

株洲县| 溆浦县| 丹凤县| 临漳县| 延庆县| 孝感市| 古交市| 万年县| 巢湖市| 富蕴县| 武宁县| 神池县| 宣化县| 明光市| 崇州市| 图们市| 东方市| 罗江县| 弥渡县| 台北县| 彝良县| 湘西| 翼城县| 阜南县| 海林市| 孝义市| 门源| 乌鲁木齐县| 卓资县| 山东| 鲁山县| 盱眙县| 临猗县| 宜阳县| 河北区| 金寨县| 马尔康县| 常山县| 东兴市| 德惠市| 株洲市|