欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Spring Boot 實(shí)例代碼之通過(guò)接口安全退出

 更新時(shí)間:2017年09月04日 16:20:25   作者:人二人兒  
這篇文章主要介紹了Spring Boot 實(shí)例代碼之通過(guò)接口安全退出的相關(guān)資料,需要的朋友可以參考下

1、在pom.xml中引入actuator, security依賴(lài)

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

2、在application.properties開(kāi)啟shutdown endpoint(默認(rèn)關(guān)閉)

#開(kāi)啟shutdown
endpoints.shutdown.enabled=true
#自定義api地址
endpoints.shutdown.path=/shutdown

3、開(kāi)啟密碼驗(yàn)證

對(duì)/admin目錄開(kāi)啟密碼驗(yàn)證。

endpoints.shutdown.sensitive=true
security.basic.enabled=true
security.basic.path=/admin
security.user.name=admin
security.user.password=test
management.security.roles=SUPERUSER
management.port=19888
management.context-path=/admin
management.security.enabled=true

4、發(fā)送關(guān)閉HTTP請(qǐng)求

curl -u "admin:test" -X POST http://127.0.0.1:19888/admin/shutdown

5、返回內(nèi)容

{
  "message": "Shutting down, bye..."
}

總結(jié)

以上所述是小編給大家介紹的Spring Boot 實(shí)例代碼之通過(guò)接口安全退出,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論