From 2388c8c46da9ff44b85ea6cae00df18f8c7bcaa6 Mon Sep 17 00:00:00 2001 From: chenrui Date: Thu, 20 Feb 2025 10:43:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[QQYUN-10958]=E5=88=A0=E9=99=A4jeecgboot?= =?UTF-8?q?=E4=B8=AD=E7=9A=84MongoAutoConfiguration,=E5=9B=A0=E4=B8=BAjm-n?= =?UTF-8?q?osql=E4=B8=AD=E5=B7=B2=E7=BB=8F=E6=9C=89=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mongo/MongoAutoConfiguration.java | 64 ------------------- 1 file changed, 64 deletions(-) delete mode 100644 jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java deleted file mode 100644 index b4480722..00000000 --- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java +++ /dev/null @@ -1,64 +0,0 @@ -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by Fernflower decompiler) -// - -package org.springframework.boot.autoconfigure.mongo; - -import com.mongodb.MongoClientSettings; -import com.mongodb.client.MongoClient; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.mongo.MongoClientFactory; -import org.springframework.boot.autoconfigure.mongo.MongoClientSettingsBuilderCustomizer; -import org.springframework.boot.autoconfigure.mongo.MongoProperties; -import org.springframework.boot.autoconfigure.mongo.MongoPropertiesClientSettingsBuilderCustomizer; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.core.env.Environment; - -import java.util.List; -import java.util.stream.Collectors; - -@Primary -@AutoConfiguration -@ConditionalOnClass({MongoClient.class}) -@ConditionalOnProperty(name = "spring.data.mongodb.uri", havingValue = "", matchIfMissing = false) -@EnableConfigurationProperties({MongoProperties.class}) -@ConditionalOnMissingBean( - type = {"org.springframework.data.mongodb.MongoDatabaseFactory"} -) -public class MongoAutoConfiguration { - public MongoAutoConfiguration() { - } - - @Bean - @ConditionalOnMissingBean({MongoClient.class}) - public MongoClient mongo(ObjectProvider builderCustomizers, MongoClientSettings settings) { - return (MongoClient)(new MongoClientFactory((List)builderCustomizers.orderedStream().collect(Collectors.toList()))).createMongoClient(settings); - } - - @Configuration( - proxyBeanMethods = false - ) - @ConditionalOnMissingBean({MongoClientSettings.class}) - static class MongoClientSettingsConfiguration { - MongoClientSettingsConfiguration() { - } - - @Bean - MongoClientSettings mongoClientSettings() { - return MongoClientSettings.builder().build(); - } - - @Bean - MongoPropertiesClientSettingsBuilderCustomizer mongoPropertiesCustomizer(MongoProperties properties, Environment environment) { - return new MongoPropertiesClientSettingsBuilderCustomizer(properties, environment); - } - } -} From 03b6d20fcb059deeb882f7a9e031fc019b5b94f7 Mon Sep 17 00:00:00 2001 From: EightMonth Date: Mon, 24 Feb 2025 17:33:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20#7702?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/JeecgBootExceptionHandler.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java index c997cad0..18965999 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java @@ -23,7 +23,9 @@ import org.springframework.dao.DuplicateKeyException; import org.springframework.data.redis.connection.PoolException; import org.springframework.http.HttpStatus; import org.springframework.util.CollectionUtils; +import org.springframework.validation.ObjectError; import org.springframework.web.HttpRequestMethodNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestControllerAdvice; @@ -33,6 +35,7 @@ import org.springframework.web.servlet.NoHandlerFoundException; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.Map; +import java.util.stream.Collectors; /** * 异常处理器 @@ -47,6 +50,13 @@ public class JeecgBootExceptionHandler { @Resource BaseCommonService baseCommonService; + @ExceptionHandler(MethodArgumentNotValidException.class) + public Result handleValidationExceptions(MethodArgumentNotValidException e) { + log.error(e.getMessage(), e); + addSysLog(e); + return Result.error("校验失败!" + e.getBindingResult().getAllErrors().stream().map(ObjectError::getDefaultMessage).collect(Collectors.joining(","))); + } + /** * 处理自定义异常 */