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

Spring Boot 實例代碼之通過接口安全退出

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

1、在pom.xml中引入actuator, security依賴

    <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開啟shutdown endpoint(默認(rèn)關(guān)閉)

#開啟shutdown
endpoints.shutdown.enabled=true
#自定義api地址
endpoints.shutdown.path=/shutdown

3、開啟密碼驗證

對/admin目錄開啟密碼驗證。

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請求

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

5、返回內(nèi)容

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

總結(jié)

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

相關(guān)文章

最新評論