Browse Source

update

for_java17
许孟阳 3 years ago
parent
commit
1ae24b874c
  1. 6
      pom.xml
  2. 11
      src/main/java/vip/xumy/core/exception/ControllerExceptionHandler.java

6
pom.xml

@ -47,12 +47,6 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- spring-boot整合mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring-boot.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>

11
src/main/java/vip/xumy/core/exception/ControllerExceptionHandler.java

@ -4,7 +4,6 @@ import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
@ -28,11 +27,11 @@ public class ControllerExceptionHandler {
return new AjaxResponse(false, e.getMessage()); return new AjaxResponse(false, e.getMessage());
} }
@ResponseBody // @ResponseBody
@ExceptionHandler(DuplicateKeyException.class) // @ExceptionHandler(DuplicateKeyException.class)
public AjaxResponse handlerDuplicateKeyException(DuplicateKeyException e) { // public AjaxResponse handlerDuplicateKeyException(DuplicateKeyException e) {
return new AjaxResponse(false, "数据已存在,请勿重复添加"); // return new AjaxResponse(false, "数据已存在,请勿重复添加");
} // }
@ResponseBody @ResponseBody
@ExceptionHandler(SQLException.class) @ExceptionHandler(SQLException.class)

Loading…
Cancel
Save