网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

spring boot全局异常处理

时间:2024-10-11 22:30:11

1、通过intellij idea创建spring boot项目,如下图所示

spring boot全局异常处理

3、创建一个测试controller方法,然后返回异常,代码如下@RestController@RequestMapping("/test")public class TestController { @RequestMapping("") public Map test(@RequestBody Map map) throws Exception { if (1==1){ throw new Exception("1111111111"); } return map; }}

spring boot全局异常处理

5、启动程序,访问rest接口

spring boot全局异常处理
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com