您的位置:首页 > 产品设计 > UI/UE

Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource

2018-08-13 21:09 811 查看
出现问题=有很多,下面的是一种。有些人不小心造成的。
错误所在,上下的这两个方法,有没有发现请求路径都是一样的,虽然你跟的参数不一样,但是还是会报错,**
报出问题: 方法初始化失败,也就是springboot找不到应该请求哪个路径。
解决办法,  可以将其中的一个@GetMapping修改为  @RequestMapping即可解决异常.  亲测

@Autowired
private SpecifacationService specifacationService;
@GetMapping("/params")
public ResponseEntity<List<SpecParam>> queryParamByCategoryId(
@RequestParam(value = "gid", required = false) Long gid,
@RequestParam(value = "cid", required = false) Long cid,
@RequestParam(value = "searching", required = false) Boolean searching,
@RequestParam(value = "generic", required = false) Boolean generic) {

List<SpecParam> list = this.specifacationService.querySpecParams(gid, cid, searching, generic);
if (list == null || list.size() == 0) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return ResponseEntity.ok(list);
}

//查询组里面的参数信息
**@GetMapping("/params")**
public ResponseEntity<List<SpecParam>> queryParamBygid(@RequestParam(value = "gid", defaultValue = "1") Long gid) {
List<SpecParam> listParam = specifacationService.queryParamBygid(gid);
if (CollectionUtils.isEmpty(listParam)) {

return ResponseEntity.notFound().build();
}

return ResponseEntity.ok(listParam);

}

2018-8-13   记.
阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐