diff --git a/jcommon/docean-plugin/docean-plugin-configuration/src/main/java/com/xiaomi/youpin/docean/plugin/configuration/ConfigurationPlugin.java b/jcommon/docean-plugin/docean-plugin-configuration/src/main/java/com/xiaomi/youpin/docean/plugin/configuration/ConfigurationPlugin.java index e78431c34..37d10ecad 100644 --- a/jcommon/docean-plugin/docean-plugin-configuration/src/main/java/com/xiaomi/youpin/docean/plugin/configuration/ConfigurationPlugin.java +++ b/jcommon/docean-plugin/docean-plugin-configuration/src/main/java/com/xiaomi/youpin/docean/plugin/configuration/ConfigurationPlugin.java @@ -38,7 +38,7 @@ * @author shanwb * @date 2022-09-13 */ -@DOceanPlugin(order = Integer.MAX_VALUE) +@DOceanPlugin(order = Integer.MAX_VALUE - 2) @Slf4j public class ConfigurationPlugin implements IPlugin { diff --git a/jcommon/docean-plugin/docean-plugin-mybatis-plus/src/main/java/com/xiaomi/youpin/docean/plugin/mybatisplus/MybatisPlugin.java b/jcommon/docean-plugin/docean-plugin-mybatis-plus/src/main/java/com/xiaomi/youpin/docean/plugin/mybatisplus/MybatisPlugin.java index 76035713b..37278b1d2 100644 --- a/jcommon/docean-plugin/docean-plugin-mybatis-plus/src/main/java/com/xiaomi/youpin/docean/plugin/mybatisplus/MybatisPlugin.java +++ b/jcommon/docean-plugin/docean-plugin-mybatis-plus/src/main/java/com/xiaomi/youpin/docean/plugin/mybatisplus/MybatisPlugin.java @@ -16,6 +16,7 @@ package com.xiaomi.youpin.docean.plugin.mybatisplus; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.xiaomi.youpin.docean.Aop; import com.xiaomi.youpin.docean.Ioc; import com.xiaomi.youpin.docean.anno.DOceanPlugin; @@ -33,6 +34,7 @@ import org.apache.ibatis.plugin.Interceptor; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; +import org.springframework.util.CollectionUtils; import javax.sql.DataSource; import java.lang.reflect.InvocationHandler; @@ -47,7 +49,7 @@ /** * @author goodjava@qq.com */ -@DOceanPlugin +@DOceanPlugin(order = Integer.MAX_VALUE - 1) @Slf4j public class MybatisPlugin implements IPlugin { @@ -93,6 +95,11 @@ private void addDAO(Ioc ioc, String beanName, String mapperLocation, boolean one bean.setPlugins(new Interceptor[]{interceptor}); } + Set plusInterceptors = ioc.getBeans(MybatisPlusInterceptor.class); + if (!CollectionUtils.isEmpty(plusInterceptors)) { + bean.setPlugins(plusInterceptors.toArray(new Interceptor[]{})); + } + SqlSessionFactory factory = bean.buildSqlSessionFactory(); ioc.putBean("mybatis_" + beanName + config.getName(), factory);