Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource
@RequestMapping(“/spec”)@Controllerpublic class SpecController {@Autowiredprivate SpecifacationService specifacationService;//查询组的信息@GetMapping("/groups/{cid}")public Respons
·
出现问题=有很多,下面的是一种。有些人不小心造成的。
错误所在,上下的这两个方法,有没有发现请求路径都是一样的,虽然你跟的参数不一样,但是还是会报错,**
报出问题: 方法初始化失败,也就是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 记.
更多推荐
已为社区贡献1条内容
所有评论(0)