引入lombok + 支持构建jar包

This commit is contained in:
白茶清欢 2025-06-02 19:27:39 +08:00
parent e017917f16
commit c2b65a6be8
4 changed files with 24 additions and 11 deletions

View File

@ -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>

View File

@ -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;
}
}

View File

@ -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() {

View File

@ -0,0 +1,5 @@
package cn.zhangdeman;
public class Main {
public static void main(String[] args) {}
}