【发布时间】:2022-01-07 15:52:56
【问题描述】:
默认错误处理不会返回正确的信息; 我将SpringBoot版本从2.5.2升级到2.6.2 案例场景: 发送没有认证的get方法:
邮递员对 springBoot 2.6.2 的回应: springBoot version 2.6.2
邮递员对 springBoot 2.5.2 的回应: springBoot version 2.5.2
缺少返回内容是预期的行为吗? 我打算使用@ControllerAdvice 来解决这个问题。
项目详情:
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
【问题讨论】:
-
Spring Boot 2.6.2更新后的响应代码是什么?401或500?
标签: spring-boot security error-handling