引入lombok + 支持构建jar包
This commit is contained in:
parent
e017917f16
commit
c2b65a6be8
7
pom.xml
7
pom.xml
@ -17,7 +17,12 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>5.3.22</version>
|
||||
<version>6.1.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.24</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -1,30 +1,31 @@
|
||||
package cn.zhangdeman;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
// 自定义异常
|
||||
@Getter
|
||||
@Setter
|
||||
public class CustomException extends RuntimeException {
|
||||
private final Object code; // 错误码
|
||||
private final String code; // 错误码
|
||||
private final String message; // 异常信息
|
||||
private final Object data; // 异常数据
|
||||
public CustomException(String message) {
|
||||
super(message);
|
||||
this.code = -1;
|
||||
this.code = "-1";
|
||||
this.data = null;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
// 根据code与
|
||||
public CustomException(Object code, Object data) {
|
||||
public CustomException(String code, Object data) {
|
||||
this.code = code;
|
||||
this.message = ""; // TODO : 根据code初始化Message
|
||||
this.message = HashMapCache.getHashMapCache().getCodeMessage(code); // 根据code初始化Message
|
||||
this.data = data;
|
||||
}
|
||||
public CustomException(Object code, String message, Object data) {
|
||||
public CustomException(String code, String message, Object data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -27,7 +28,8 @@ public class HashMapCache {
|
||||
assert customExceptionAnnotation != null;
|
||||
String[] scanPackageList = customExceptionAnnotation.exceptionPackageList();
|
||||
String[] scanExceptionClassList = customExceptionAnnotation.exceptionClassList();
|
||||
System.out.println(scanExceptionClassList, scanPackageList);
|
||||
System.out.println(Arrays.toString(scanExceptionClassList));
|
||||
System.out.println(Arrays.toString(scanPackageList));
|
||||
}
|
||||
}
|
||||
public static HashMapCache getHashMapCache() {
|
||||
|
5
src/main/java/cn/zhangdeman/Main.java
Normal file
5
src/main/java/cn/zhangdeman/Main.java
Normal file
@ -0,0 +1,5 @@
|
||||
package cn.zhangdeman;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user