mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
optimize DbAutoConfiguration
This commit is contained in:
parent
5c4430e8d2
commit
a258d66dd4
@ -39,7 +39,8 @@ public class Db {
|
||||
|
||||
public static RowMapperInvoker invoker() {
|
||||
if (defaultRowMapperInvoker == null) {
|
||||
SqlSessionFactory sqlSessionFactory = FlexGlobalConfig.getDefaultConfig().getSqlSessionFactory();
|
||||
FlexGlobalConfig defaultConfig = FlexGlobalConfig.getDefaultConfig();
|
||||
SqlSessionFactory sqlSessionFactory = defaultConfig.getSqlSessionFactory();
|
||||
defaultRowMapperInvoker = new RowMapperInvoker(sqlSessionFactory);
|
||||
}
|
||||
return defaultRowMapperInvoker;
|
||||
|
||||
@ -15,18 +15,27 @@
|
||||
*/
|
||||
package com.mybatisflex.spring.boot;
|
||||
|
||||
import com.mybatisflex.core.FlexGlobalConfig;
|
||||
import com.mybatisflex.core.row.Db;
|
||||
import com.mybatisflex.spring.SpringRowSessionManager;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ConditionalOnClass(Db.class)
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@AutoConfigureAfter({MybatisFlexAutoConfiguration.class})
|
||||
public class DbAutoConfiguration {
|
||||
|
||||
public DbAutoConfiguration() {
|
||||
FlexGlobalConfig defaultConfig = FlexGlobalConfig.getDefaultConfig();
|
||||
if (defaultConfig == null){
|
||||
Logger.getLogger(Db.class.getName()).log(Level.WARNING,"Cannot get FlexGlobalConfig instance, Perhaps the dataSource config error.");
|
||||
}else {
|
||||
Db.invoker().setRowSessionManager(new SpringRowSessionManager());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user