小编np1*_*p10的帖子

springboot API 抛出 500 错误但没有记录错误

我有一个 springboot api。从 swagger 调用端点之一会抛出 500 错误,但没有记录任何内容。当我尝试调试时,我可以看到在从控制器返回之前填充了responseEntity。因此我觉得代码工作得很好。即便如此,我还是看到 500 神气十足。缺乏日志使得调试变得困难。有人遇到类似的问题吗?你是怎么解决的?

\n\n

端点看起来像这样:我添加了日志语句以供参考

\n\n
@RequestMapping(value = "/details/id/{id}", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})\n    public @ResponseBody\n    ResponseEntity<Details> getDetailsById(@PathVariable(name="id")  @ApiParam(value ="id", example = "1234", required = true) String id) {\n        inputValidation.validateInputAndThrowErrorIfNecessary(id);\n        if(isBlank(id)) throw new IllegalArgumentException();\n\n        Details details = detailsService.getDetailsById(id);\n\n        if(details == null){\n            logger.debug("Not found response..................");\n            return new ResponseEntity<>(HttpStatus.NOT_FOUND);\n        }\n        logger.debug("Just before posting the response for  : {}", id);\n        ResponseEntity<Details> responseEntity = new ResponseEntity<>(details, HttpStatus.OK);\n        logger.debug("JSON--->\\n"+responseEntity.toString()); // i see <200 OK OK,class Details { blah …
Run Code Online (Sandbox Code Playgroud)

internal-server-error spring-boot

9
推荐指数
1
解决办法
4637
查看次数

标签 统计

internal-server-error ×1

spring-boot ×1