赞
踩
看镜像版本
curl pod_ip:pod_port/服务名/请求路径 -H "请求头" -d '参数'
或者 curl server_ip:server_port/服务名/请求路径 -H "请求头" -d '参数'
两种情况
相同 请求方法,相同 请求路径 冲突了
不同 请求方法,相同 请求路径 冲突了
两个服务器上 一个冲突了,一个没冲突 :两个服务器 打包版本不一致
隐藏情况:
两个服务器上 一个冲突了,一个没冲突 ,但是两个服务器,服务版本一致
检查 服务 中是不是调用了另一个服务 -> 另一个服务 版本不一致
例如 postman 调用下面接口时
http://localhost:8080/myweb/companyList
会报错,只能使用 get 方法
原因是 和下面的 post 方法 url 冲突了
@ApiOperation(value = "用户详情", notes = "用户详情", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(value = "/{platformSerial}")
public DeferredResult<ResponseEntity<BaseResult<PlatformVo>>> userDetail(@ApiParam(value = "用户编号", required = true) @PathVariable("userSerial") String userSerial) {
return ok(userServiceApi.userDetail(userSerial));
}
@ApiOperation(value = "公司信息列表", notes = "公司信息列表", httpMethod = "POST")
@PostMapping(value = "/companyList")
public DeferredResult<ResponseEntity<BaseResult<CompanyInfo>>> companyInfo(@Valid @RequestBody CompanyFilterRequest request) {
return ok(companyServiceApi.companyList(request));
}
post url 方法改为 即可避免冲突
@PostMapping(value = "/company/ist")
下面接口会冲突
@RestController public class StudentController { @RequestMapping(value = "/student/detail/{id}/{name}") public Object student2(@PathVariable("id") Integer id, @PathVariable("name") String name){ ... return student; } @RequestMapping(value = "/student/detail/{id}/{detail}") public Object student3(@PathVariable("id") Integer id, @PathVariable("detail") String detail){ ... return student; } }
方案一:将@RequestMapping改成PostMapping或者@DeleteMapping等注解
@PostMapping(value = "/student/detail/{id}/{detail}")
public Object student3(@PathVariable("id") Integer id,
@PathVariable("detail") String detail){
...
return student;
}
方案二:改变请求路径
@RequestMapping(value = "/student/{id}/detail/{detail}")
public Object student3(@PathVariable("id") Integer id,
@PathVariable("detail") String detail){
...
return student;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。