Skip to content

Commit

Permalink
bom 文件调整
Browse files Browse the repository at this point in the history
  • Loading branch information
YunaiV committed Jul 17, 2020
1 parent 26ea8dd commit e3f2e15
Show file tree
Hide file tree
Showing 87 changed files with 382 additions and 1,897 deletions.
36 changes: 17 additions & 19 deletions common/common-framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,47 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>

<!-- RPC 相关 -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<optional>true</optional>
</dependency>

<!-- 监控相关 -->
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-trace</artifactId>
<optional>true</optional>
</dependency>

<!-- 日志相关 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<optional>true</optional>
</dependency>

<!-- 测试相关 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>

<!-- 工具相关 -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<optional>true</optional>
</dependency>

<dependency>
Expand All @@ -62,21 +70,11 @@
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<optional>true</optional>
</dependency>

<!-- hutool 工具集,减少重复开发各种Util-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ public Integer getCode() {
return code;
}



}
Original file line number Diff line number Diff line change
@@ -1,52 +1,9 @@
package cn.iocoder.common.framework.util;

import cn.iocoder.common.framework.exception.ServiceException;
import org.apache.commons.lang3.exception.ExceptionUtils;

import javax.validation.ConstraintViolationException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.UndeclaredThrowableException;

public class ExceptionUtil {

public static ServiceException getServiceException(Exception e) {
if (e instanceof UndeclaredThrowableException) {
return getServiceException((UndeclaredThrowableException) e);
}
return null;
}

// 处理 Spring 动态代理调用时,发生 UndeclaredThrowableException 的情况。
// 不了解的胖友,可以先看看 https://segmentfault.com/a/1190000012262244 文章
// 原因是:
// 1. Dubbo 动态代理 Wrapper 会将抛出的异常,包装成 InvocationTargetException 异常
// 2. Spring AOP 发现是 InvocationTargetException 异常是非方法定义的异常,则会包装成 UndeclaredThrowableException 异常。
@Deprecated // https://github.com/apache/incubator-dubbo/issues/3386 Dubbo 2.6.5 会触发该问题,在 2.7.1 版本已经解决。
public static ServiceException getServiceException(UndeclaredThrowableException e) {
Throwable undeclaredThrowable = e.getUndeclaredThrowable();
if (undeclaredThrowable instanceof InvocationTargetException) {
InvocationTargetException invocationTargetException = (InvocationTargetException) undeclaredThrowable;
Throwable targetException = invocationTargetException.getTargetException();
if (targetException != null & targetException instanceof ServiceException) {
return (ServiceException) targetException;
}
}
return null;
}

@Deprecated // https://github.com/apache/incubator-dubbo/issues/3386 Dubbo 2.6.5 会触发该问题,在 2.7.1 版本已经解决。
public static ConstraintViolationException getConstraintViolationException(UndeclaredThrowableException e) {
Throwable undeclaredThrowable = e.getUndeclaredThrowable();
if (undeclaredThrowable instanceof InvocationTargetException) {
InvocationTargetException invocationTargetException = (InvocationTargetException) undeclaredThrowable;
Throwable targetException = invocationTargetException.getTargetException();
if (targetException instanceof ConstraintViolationException) {
return (ConstraintViolationException) targetException;
}
}
return null;
}

public static String getMessage(Throwable th) {
return ExceptionUtils.getMessage(th);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import cn.iocoder.common.framework.enums.GlobalErrorCodeEnum;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.util.Assert;

import java.io.Serializable;
Expand Down Expand Up @@ -95,12 +95,12 @@ public CommonResult<T> setDetailMessage(String detailMessage) {
return this;
}

@JsonIgnore
@JSONField(serialize = false) // 避免序列化
public boolean isSuccess() {
return CODE_SUCCESS.equals(code);
}

@JsonIgnore
@JSONField(serialize = false) // 避免序列化
public boolean isError() {
return !isSuccess();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,41 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>demo</artifactId>
<artifactId>common</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>

<artifactId>demo-business-api</artifactId>
<artifactId>mall-spring-boot-starter-dubbo</artifactId>

<dependencies>
<!-- Mall 相关 -->
<!-- 通用相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>

<!-- Web 相关 -->
<!-- RPC 相关 -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>

<!-- 工具类相关 -->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId> <!-- use mapstruct-jdk8 for Java 8 or higher -->
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
</dependency>

<!-- 日志相关 -->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<!-- 工具相关 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
</dependencies>

Expand Down
Loading

0 comments on commit e3f2e15

Please sign in to comment.