解決辦法【設置端點訪問 】:
1, 關閉驗證
management.security.enabled=false
2,開啟HTTP basic認證
- 添加依賴
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
- application.properties 添加用戶名和密碼
security.user.name=admin
security.user.password=123456
management.security.enabled=true
management.security.role=ADMIN
訪問URL http://localhost:8080/env 后,就看到需要輸入用戶名和密碼了