diff --git a/example/example-app/example-app-cmd-domain/pom.xml b/example/example-app/example-app-cmd-domain/pom.xml
index 39cafdfd..a4958f91 100644
--- a/example/example-app/example-app-cmd-domain/pom.xml
+++ b/example/example-app/example-app-cmd-domain/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-app
- 3.4.31
+ 3.4.32
../pom.xml
diff --git a/example/example-app/example-app-cmd-meta/pom.xml b/example/example-app/example-app-cmd-meta/pom.xml
index 11902b7c..4059e771 100644
--- a/example/example-app/example-app-cmd-meta/pom.xml
+++ b/example/example-app/example-app-cmd-meta/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-app
- 3.4.31
+ 3.4.32
../pom.xml
diff --git a/example/example-app/example-app-query/pom.xml b/example/example-app/example-app-query/pom.xml
index de94be83..803d1bed 100644
--- a/example/example-app/example-app-query/pom.xml
+++ b/example/example-app/example-app-query/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-app
- 3.4.31
+ 3.4.32
../pom.xml
diff --git a/example/example-app/pom.xml b/example/example-app/pom.xml
index 3519ffad..f73355d9 100644
--- a/example/example-app/pom.xml
+++ b/example/example-app/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-example
- 3.4.31
+ 3.4.32
../pom.xml
pom
diff --git a/example/example-domain/example-domain-leave/pom.xml b/example/example-domain/example-domain-leave/pom.xml
index 5c1b1ef4..eb3896d5 100644
--- a/example/example-domain/example-domain-leave/pom.xml
+++ b/example/example-domain/example-domain-leave/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-domain
- 3.4.31
+ 3.4.32
../pom.xml
diff --git a/example/example-domain/example-domain-user/pom.xml b/example/example-domain/example-domain-user/pom.xml
index 1b0361c1..ab9b9c3d 100644
--- a/example/example-domain/example-domain-user/pom.xml
+++ b/example/example-domain/example-domain-user/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-domain
- 3.4.31
+ 3.4.32
../pom.xml
diff --git a/example/example-domain/pom.xml b/example/example-domain/pom.xml
index f0d03cb9..ecaee85c 100644
--- a/example/example-domain/pom.xml
+++ b/example/example-domain/pom.xml
@@ -5,7 +5,7 @@
com.codingapi.springboot
springboot-example
- 3.4.31
+ 3.4.32
../pom.xml
4.0.0
diff --git a/example/example-infra/example-infra-flow/pom.xml b/example/example-infra/example-infra-flow/pom.xml
index 73679818..86fb582a 100644
--- a/example/example-infra/example-infra-flow/pom.xml
+++ b/example/example-infra/example-infra-flow/pom.xml
@@ -5,7 +5,7 @@
com.codingapi.springboot
example-infra
- 3.4.31
+ 3.4.32
../pom.xml
diff --git a/example/example-infra/example-infra-jpa/pom.xml b/example/example-infra/example-infra-jpa/pom.xml
index 58c8aa1f..88e06217 100644
--- a/example/example-infra/example-infra-jpa/pom.xml
+++ b/example/example-infra/example-infra-jpa/pom.xml
@@ -5,7 +5,7 @@
com.codingapi.springboot
example-infra
- 3.4.31
+ 3.4.32
../pom.xml
diff --git a/example/example-infra/example-infra-security/pom.xml b/example/example-infra/example-infra-security/pom.xml
index 91101e24..b1fd9d22 100644
--- a/example/example-infra/example-infra-security/pom.xml
+++ b/example/example-infra/example-infra-security/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-infra
- 3.4.31
+ 3.4.32
../pom.xml
diff --git a/example/example-infra/pom.xml b/example/example-infra/pom.xml
index 0d6ac055..4e1c56e7 100644
--- a/example/example-infra/pom.xml
+++ b/example/example-infra/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-example
- 3.4.31
+ 3.4.32
../pom.xml
pom
diff --git a/example/example-interface/pom.xml b/example/example-interface/pom.xml
index f016fe20..7689b9fe 100644
--- a/example/example-interface/pom.xml
+++ b/example/example-interface/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-example
- 3.4.31
+ 3.4.32
example-interface
diff --git a/example/example-interface/src/main/java/com/codingapi/example/api/domain/ErrorController.java b/example/example-interface/src/main/java/com/codingapi/example/api/domain/ErrorController.java
new file mode 100644
index 00000000..b6bc9ae9
--- /dev/null
+++ b/example/example-interface/src/main/java/com/codingapi/example/api/domain/ErrorController.java
@@ -0,0 +1,27 @@
+package com.codingapi.example.api.domain;
+
+import com.codingapi.springboot.framework.dto.response.Response;
+import com.codingapi.springboot.framework.exception.LocaleMessageException;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/open/error")
+public class ErrorController {
+
+ @GetMapping("/error1")
+ public Response error1(){
+ throw new LocaleMessageException("error1");
+ }
+
+ @GetMapping("/error2")
+ public Response error2(){
+ throw new LocaleMessageException("error2","error 2 message");
+ }
+
+ @GetMapping("/error3")
+ public Response error3(){
+ throw new LocaleMessageException("error3",new Object[]{"my is arg"});
+ }
+}
diff --git a/example/example-server/pom.xml b/example/example-server/pom.xml
index 05346d8b..42885df6 100644
--- a/example/example-server/pom.xml
+++ b/example/example-server/pom.xml
@@ -5,7 +5,7 @@
springboot-example
com.codingapi.springboot
- 3.4.31
+ 3.4.32
4.0.0
diff --git a/example/example-server/src/main/resources/messages.properties b/example/example-server/src/main/resources/messages.properties
new file mode 100644
index 00000000..ee1aa252
--- /dev/null
+++ b/example/example-server/src/main/resources/messages.properties
@@ -0,0 +1,2 @@
+error1= Error 1
+error3= Error 3 {0}
\ No newline at end of file
diff --git a/example/example-server/src/main/resources/messages_zh_CN.properties b/example/example-server/src/main/resources/messages_zh_CN.properties
new file mode 100644
index 00000000..9da56622
--- /dev/null
+++ b/example/example-server/src/main/resources/messages_zh_CN.properties
@@ -0,0 +1,2 @@
+error1= 错误 1
+error3= 错误 3 {0}
\ No newline at end of file
diff --git a/example/pom.xml b/example/pom.xml
index 05f834f3..e601bca9 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -19,7 +19,7 @@
springboot-example
- 3.4.31
+ 3.4.32
springboot-example
springboot-example project for Spring Boot
diff --git a/pom.xml b/pom.xml
index 2219b9e0..008a30e2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
com.codingapi.springboot
springboot-parent
- 3.4.31
+ 3.4.32
https://github.com/codingapi/springboot-framewrok
springboot-parent
diff --git a/springboot-starter-data-authorization/pom.xml b/springboot-starter-data-authorization/pom.xml
index cd38a126..0f4ffbfd 100644
--- a/springboot-starter-data-authorization/pom.xml
+++ b/springboot-starter-data-authorization/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-parent
- 3.4.31
+ 3.4.32
springboot-starter-data-authorization
diff --git a/springboot-starter-data-fast/pom.xml b/springboot-starter-data-fast/pom.xml
index bd7ceaa2..043e621b 100644
--- a/springboot-starter-data-fast/pom.xml
+++ b/springboot-starter-data-fast/pom.xml
@@ -5,7 +5,7 @@
springboot-parent
com.codingapi.springboot
- 3.4.31
+ 3.4.32
4.0.0
diff --git a/springboot-starter-flow/pom.xml b/springboot-starter-flow/pom.xml
index d42d1ad6..1e3fac06 100644
--- a/springboot-starter-flow/pom.xml
+++ b/springboot-starter-flow/pom.xml
@@ -6,7 +6,7 @@
springboot-parent
com.codingapi.springboot
- 3.4.31
+ 3.4.32
springboot-starter-flow
diff --git a/springboot-starter-security/pom.xml b/springboot-starter-security/pom.xml
index e58d32d5..81ebff51 100644
--- a/springboot-starter-security/pom.xml
+++ b/springboot-starter-security/pom.xml
@@ -6,7 +6,7 @@
springboot-parent
com.codingapi.springboot
- 3.4.31
+ 3.4.32
springboot-starter-security
diff --git a/springboot-starter/pom.xml b/springboot-starter/pom.xml
index 2d1cf20d..5d47f07f 100644
--- a/springboot-starter/pom.xml
+++ b/springboot-starter/pom.xml
@@ -5,7 +5,7 @@
com.codingapi.springboot
springboot-parent
- 3.4.31
+ 3.4.32
springboot-starter
diff --git a/springboot-starter/src/main/java/com/codingapi/springboot/framework/exception/LocaleMessageException.java b/springboot-starter/src/main/java/com/codingapi/springboot/framework/exception/LocaleMessageException.java
index 44e2c08a..18e482ff 100644
--- a/springboot-starter/src/main/java/com/codingapi/springboot/framework/exception/LocaleMessageException.java
+++ b/springboot-starter/src/main/java/com/codingapi/springboot/framework/exception/LocaleMessageException.java
@@ -17,22 +17,48 @@ public LocaleMessageException(String errCode, String errMessage, Throwable cause
this.errMessage = errMessage;
}
- public LocaleMessageException(String errCode, Throwable cause) {
+ public LocaleMessageException(String errCode,Throwable cause) {
super(MessageContext.getInstance().getErrorMsg(errCode), cause);
this.errCode = errCode;
this.errMessage = getMessage();
}
+
+ public LocaleMessageException(String errCode,Object[] args, Throwable cause) {
+ super(MessageContext.getInstance().getErrorMsg(errCode,args), cause);
+ this.errCode = errCode;
+ this.errMessage = getMessage();
+ }
+
public LocaleMessageException(String errCode, String errMessage) {
super(errMessage);
this.errCode = errCode;
this.errMessage = errMessage;
}
+ public LocaleMessageException(String errCode,Object[] args) {
+ super(MessageContext.getInstance().getErrorMsg(errCode,args));
+ this.errCode = errCode;
+ this.errMessage = getMessage();
+ }
+
public LocaleMessageException(String errCode) {
super(MessageContext.getInstance().getErrorMsg(errCode));
this.errCode = errCode;
this.errMessage = getMessage();
}
+
+ /**
+ * 占位符异常,在message.properties中配置错误信息,占位符参数从0开始实例如下
+ * error3= 错误 3 {0} {1}
+ * @param errCode 错误码
+ * @param args 占位符参数
+ * @return 异常
+ */
+ public static LocaleMessageException of(String errCode, Object ...args) {
+ return new LocaleMessageException(errCode, args);
+ }
+
+
}
diff --git a/springboot-starter/src/main/java/com/codingapi/springboot/framework/exception/MessageContext.java b/springboot-starter/src/main/java/com/codingapi/springboot/framework/exception/MessageContext.java
index e2c43d4e..76dd1231 100644
--- a/springboot-starter/src/main/java/com/codingapi/springboot/framework/exception/MessageContext.java
+++ b/springboot-starter/src/main/java/com/codingapi/springboot/framework/exception/MessageContext.java
@@ -24,7 +24,12 @@ void setExceptionLocaleMessage(LocaleMessage localeMessage) {
}
public String getErrorMsg(String errCode) {
- return localeMessage.getMessage(errCode);
+ return this.getErrorMsg(errCode,null);
+ }
+
+
+ public String getErrorMsg(String errCode,Object[] args) {
+ return localeMessage.getMessage(errCode,args);
}
}