Skip to content

Commit

Permalink
修改了错误部分
Browse files Browse the repository at this point in the history
  • Loading branch information
dingliqiang committed Nov 9, 2019
1 parent 46f88fe commit 57f430c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public String createMyException() throws MyException {
* 抛出空指针异常,测试全局异常处理器
*/
@GetMapping("/exception")
public String createGlobleException() throws NullPointerException {
public String createGlobleException() {
throw new NullPointerException("NullPointerException 空指针异常信息");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
//@RestControllerAdvice代替@ControllerAdvice,这样在方法上就可以不需要添加@ResponseBody
@RestControllerAdvice(basePackages = "club.mydlq")
public class ExceptionHandler {
public class GlobalExceptionHandler {

/**
* MyException异常处理器
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mydlq.swagger.example;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
Expand All @@ -20,6 +21,8 @@ public Docket createRestApi() {
.select() // 选择那些路径和api会生成document
.apis(RequestHandlerSelectors.any()) // 对所有api进行监控
.paths(PathSelectors.any()) // 对所有路径进行监控
.paths(Predicates.not(PathSelectors.regex("/error.*")))//错误路径不监控
.paths(Predicates.not(PathSelectors.regex("/actuator.*")))//actuator路径跳过
.build();
}

Expand Down

0 comments on commit 57f430c

Please sign in to comment.