springboot 的retry与全局异常处理
1、使用自定义错误页面
Springboot的错误页面提示对用户并不友好,所以我们可以自定义我们的错误页面。在/src/main/resources/static目录下新建一个404.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>出错啦</title>
</head>
<body>
<div class="text" style="text-align: center">
<h1>对不起,您要找的页面消失啦!!!</h1>
</div>
</body>
</html>
在项目下新建一个error包,再新建一个ErrorConfig配置类,代码如下
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
/*
* 描述:自定义错误页面
* ye
* 2020.11.07
* */
@Configuration
public class