1. 优化异常拦截

2. pom引用调整
master
陈峰 1 year ago
parent 12e0025ef6
commit 73bd09b9b4
  1. 13
      framework-core/pom.xml
  2. 11
      framework-core/src/main/java/com/unionmed/framework/spring/mvc/ExceptionHandler.java
  3. 9
      pom.xml

@ -5,7 +5,7 @@
<parent>
<groupId>com.unionmed</groupId>
<artifactId>unionmed-framework</artifactId>
<version>0.0.12</version>
<version>0.0.13</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -134,6 +134,10 @@
<!-- Apache: http-client -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
@ -161,11 +165,10 @@
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
</dependencies>

@ -1,7 +1,9 @@
package com.unionmed.framework.spring.mvc;
import com.unionmed.framework.exception.UmedException;
import com.unionmed.framework.util.ObjectUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
@ -23,4 +25,13 @@ public class ExceptionHandler {
log.error("系统异常", t);
return BaseReturn.fail();
}
@org.springframework.web.bind.annotation.ExceptionHandler(HttpMessageNotReadableException.class)
public Object missingRequestBody(Throwable t) {
if (ObjectUtils.notEmpty(t.getMessage()) && t.getMessage().startsWith("Required request body is missing")) {
return BaseReturn.fail("request body is missing");
}
log.error("系统异常", t);
return BaseReturn.fail();
}
}

@ -9,7 +9,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.unionmed</groupId>
<artifactId>unionmed-framework</artifactId>
<version>0.0.12</version>
<version>0.0.13</version>
<packaging>pom</packaging>
<name>unionmed-framework</name>
@ -62,6 +62,7 @@
<rxnetty.version>0.4.9</rxnetty.version>
<mksapi.version>4.10.9049</mksapi.version>
<bcprov.version>1.73</bcprov.version>
<commons-io.version>2.6</commons-io.version>
</properties>
<dependencyManagement>
@ -224,6 +225,12 @@
<version>${mksapi.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<!-- Apache: http-client -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>

Loading…
Cancel
Save