java - 如何设置 spring.boot 实现的 rest 接口的 put 方法的 Rest 客户端调用?
问题描述
我的控制器:
@Slf4j
@RestController
@RequestMapping("/technology")
@RequiredArgsConstructor
public class MyController {
private final MyService myService;
@PutMapping("/enable/{technology}")
public void useTechnology(@PathVariable String technology, Principal principal) {
myService.[...]
}
我在 application.yaml 中的用户名/密码:
security:
user:
name: user1
password: password
我的 RestClient 调用:
PUT http://localhost:8080/technology/enable/tech1
Authorization: Basic dXNlcjE6cGFzc3dvcmQx
Accept: application/json
Cache-Control: no-cache
我总是收到 401 错误:
PUT http://localhost:8080/technology/enable/tech1
HTTP/1.1 401
Set-Cookie: JSESSIONID=DFE4D6D27992A0183BE7A79B551B1EE7; Path=/; HttpOnly
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
WWW-Authenticate: Basic realm="Realm"
Content-Length: 0
Date: Thu, 08 Aug 2019 07:14:23 GMT
<Response body is empty>
Response code: 401; Time: 17ms; Content length: 0 bytes
我必须设置/更改什么才能使通话正常工作?
解决方案
推荐阅读
- ab-testing - 我可以在 Google Optimize 中为我的创建和编辑页面创建一个重定向测试吗?
- android - 在活动上拖放片段
- python-2.7 - 在 Ubuntu 18.04 中安装 Caffe 时遇到问题
- c - 当某些不是整数的无效输入时,打印语句开头的额外零
- angular - ValueChanges 事件未在 Angular 6 的第一枪中触发 - 反应形式
- powershell - 混淆使用带有 -Recurse AND -Exclude 的 Remove-Item
- c - copy_to_user 未返回预期数据
- c# - 如何从 .NET Core 2.1 Web API w/o Entity Framework 检索类中的连接字符串
- python - Django模板不呈现
- sql - '>' 附近的语法不正确