Skip to content

Commit

Permalink
解决GlobalConfig在ConfigurationCustomizer不生效的问题.
Browse files Browse the repository at this point in the history
  • Loading branch information
nieqiurong committed Nov 30, 2019
1 parent c127d67 commit e36a385
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Excepti
factory.setTypeEnumsPackage(this.properties.getTypeEnumsPackage());
}
// TODO 此处必为非 NULL
GlobalConfig globalConfig = this.properties.getGlobalConfig();
// config的优先级要大于properties
GlobalConfig globalConfig = factory.getConfiguration().hasGlobalConfig() ? factory.getConfiguration().getGlobalConfig() : this.properties.getGlobalConfig();
// TODO 注入填充器
if (this.applicationContext.getBeanNamesForType(MetaObjectHandler.class,
false, false).length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.baomidou.mybatisplus.core.executor.MybatisReuseExecutor;
import com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor;
import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils;
import lombok.Getter;
import lombok.Setter;
import org.apache.ibatis.binding.MapperRegistry;
import org.apache.ibatis.executor.Executor;
Expand Down Expand Up @@ -60,7 +59,7 @@ public GlobalConfig getGlobalConfig(){
return globalConfig;
}

public boolean hasGlobalConfig(){
public boolean hasGlobalConfig() {
return globalConfig != null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ public void setConfiguration(MybatisConfiguration configuration) {
this.configuration = configuration;
}

public MybatisConfiguration getConfiguration(){
return this.configuration;
}

/**
* Set locations of MyBatis mapper files that are going to be merged into the {@code SqlSessionFactory} configuration
* at runtime.
Expand Down

0 comments on commit e36a385

Please sign in to comment.