|
@@ -20,11 +20,7 @@ import com.baomidou.mybatisplus.core.MybatisPlusVersion;
|
|
|
import com.baomidou.mybatisplus.core.MybatisSqlSessionFactoryBuilder;
|
|
|
import com.baomidou.mybatisplus.core.MybatisXMLConfigBuilder;
|
|
|
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
|
|
-import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
|
|
|
-import com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
|
|
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
|
|
|
import lombok.Setter;
|
|
@@ -43,7 +39,6 @@ import org.apache.ibatis.session.Configuration;
|
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
import org.apache.ibatis.transaction.TransactionFactory;
|
|
|
import org.apache.ibatis.type.TypeHandler;
|
|
|
-import org.apache.ibatis.type.TypeHandlerRegistry;
|
|
|
import org.mybatis.logging.Logger;
|
|
|
import org.mybatis.logging.LoggerFactory;
|
|
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
|
@@ -141,9 +136,12 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
|
|
|
private ObjectWrapperFactory objectWrapperFactory;
|
|
|
|
|
|
/**
|
|
|
- * TODO 自定义枚举包
|
|
|
+ * 不再需要这个配置,放心删除
|
|
|
+ *
|
|
|
+ * @deprecated 2022-03-07
|
|
|
*/
|
|
|
@Setter
|
|
|
+ @Deprecated
|
|
|
private String typeEnumsPackage;
|
|
|
|
|
|
// TODO 自定义全局配置
|
|
@@ -569,39 +567,6 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
|
|
|
} else {
|
|
|
LOGGER.debug(() -> "Property 'mapperLocations' was not specified.");
|
|
|
}
|
|
|
- //延迟处理,如果需要注册,必须放置在mapper文件处理解析后.
|
|
|
- if (hasLength(this.typeEnumsPackage)) {
|
|
|
- Set<Class<?>> classes;
|
|
|
- if (typeEnumsPackage.contains(StringPool.STAR) && !typeEnumsPackage.contains(StringPool.COMMA)
|
|
|
- && !typeEnumsPackage.contains(StringPool.SEMICOLON)) {
|
|
|
- classes = scanClasses(typeEnumsPackage, null);
|
|
|
- if (classes.isEmpty()) {
|
|
|
- LOGGER.warn(() -> "Can't find class in '[" + typeEnumsPackage + "]' package. Please check your configuration.");
|
|
|
- }
|
|
|
- } else {
|
|
|
- classes = new HashSet<>();
|
|
|
- String[] typeEnumsPackageArray = tokenizeToStringArray(this.typeEnumsPackage,
|
|
|
- ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
|
|
|
- Assert.notNull(typeEnumsPackageArray, "not find typeEnumsPackage:" + typeEnumsPackage);
|
|
|
- Stream.of(typeEnumsPackageArray).forEach(typePackage -> {
|
|
|
- try {
|
|
|
- Set<Class<?>> scanTypePackage = scanClasses(typePackage, null);
|
|
|
- if (scanTypePackage.isEmpty()) {
|
|
|
- LOGGER.warn(() -> "Can't find class in '[" + typePackage + "]' package. Please check your configuration.");
|
|
|
- } else {
|
|
|
- classes.addAll(scanTypePackage);
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- throw new MybatisPlusException("Cannot scan class in '[" + typePackage + "]' package", e);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- TypeHandlerRegistry typeHandlerRegistry = targetConfiguration.getTypeHandlerRegistry();
|
|
|
- classes.stream()
|
|
|
- .filter(Class::isEnum)
|
|
|
- .filter(MybatisEnumTypeHandler::isMpEnums)
|
|
|
- .forEach(cls -> typeHandlerRegistry.register(cls, MybatisEnumTypeHandler.class));
|
|
|
- }
|
|
|
|
|
|
final SqlSessionFactory sqlSessionFactory = new MybatisSqlSessionFactoryBuilder().build(targetConfiguration);
|
|
|
|