Browse Source

去除日志警告打印.

聂秋秋 6 years ago
parent
commit
224a575b20

+ 8 - 3
mybatis-plus-support/src/main/java/com/baomidou/mybatisplus/toolkit/GlobalConfigUtils.java

@@ -13,6 +13,7 @@ import org.apache.ibatis.session.Configuration;
 import org.apache.ibatis.session.SqlSessionFactory;
 
 import com.baomidou.mybatisplus.entity.GlobalConfiguration;
+import com.baomidou.mybatisplus.entity.TableInfo;
 import com.baomidou.mybatisplus.enums.DBType;
 import com.baomidou.mybatisplus.enums.FieldStrategy;
 import com.baomidou.mybatisplus.enums.IdType;
@@ -56,9 +57,13 @@ public class GlobalConfigUtils {
      * @return
      */
     public static SqlSessionFactory currentSessionFactory(Class<?> clazz) {
-        String configMark = TableInfoHelper.getTableInfo(clazz).getConfigMark();
-        GlobalConfiguration mybatisGlobalConfig = GlobalConfigUtils.getGlobalConfig(configMark);
-        return mybatisGlobalConfig.getSqlSessionFactory();
+        TableInfo tableInfo = TableInfoHelper.getTableInfo(clazz);
+        if(tableInfo != null){
+            String configMark = tableInfo.getConfigMark();
+            GlobalConfiguration mybatisGlobalConfig = GlobalConfigUtils.getGlobalConfig(configMark);
+            return mybatisGlobalConfig.getSqlSessionFactory();
+        }
+       throw new MybatisPlusException(ClassUtils.getUserClass(clazz).getName() + " Not Found TableInfoCache.");
     }
 
     /**

+ 0 - 3
mybatis-plus-support/src/main/java/com/baomidou/mybatisplus/toolkit/TableInfoHelper.java

@@ -89,9 +89,6 @@ public class TableInfoHelper {
             }
             if(tableInfo!=null){
                 tableInfoCache.put(ClassUtils.getUserClass(clazz).getName(),tableInfo);
-            }else{
-                //找不到了,我也很绝望呀
-                throw new MybatisPlusException(ClassUtils.getUserClass(clazz).getName() + "Not Found TableInfoCache.");
             }
         }
         return tableInfo;