use of com.baomidou.mybatisplus.core.config.GlobalConfig in project solon by noear.
the class MybatisAdapterPlus method initConfiguration.
/**
* 初始化配置
*/
@Override
protected void initConfiguration(Environment environment) {
// for configuration section
config = new MybatisConfiguration(environment);
Props cfgProps = dsProps.getProp("configuration");
if (cfgProps.size() > 0) {
Utils.injectProperties(config, cfgProps);
}
// for globalConfig section
globalConfig = new GlobalConfig().setDbConfig(new GlobalConfig.DbConfig());
Props globalProps = dsProps.getProp("globalConfig");
if (globalProps.size() > 0) {
// 尝试配置注入
Utils.injectProperties(globalConfig, globalProps);
}
GlobalConfigUtils.setGlobalConfig(config, globalConfig);
}
use of com.baomidou.mybatisplus.core.config.GlobalConfig in project solon by noear.
the class MybatisSqlSessionFactoryBuilderNew method build.
@Override
public SqlSessionFactory build(Configuration configuration) {
GlobalConfig globalConfig = GlobalConfigUtils.getGlobalConfig(configuration);
Object identifierGenerator;
if (null == globalConfig.getIdentifierGenerator()) {
identifierGenerator = new DefaultIdentifierGenerator();
globalConfig.setIdentifierGenerator((IdentifierGenerator) identifierGenerator);
} else {
identifierGenerator = globalConfig.getIdentifierGenerator();
}
IdWorker.setIdentifierGenerator((IdentifierGenerator) identifierGenerator);
if (globalConfig.isEnableSqlRunner()) {
(new SqlRunnerInjector()).inject(configuration);
}
SqlSessionFactory sqlSessionFactory = super.build(configuration);
globalConfig.setSqlSessionFactory(sqlSessionFactory);
Aop.getAsyn(MetaObjectHandler.class, bw -> {
globalConfig.setMetaObjectHandler(bw.get());
});
return sqlSessionFactory;
}
use of com.baomidou.mybatisplus.core.config.GlobalConfig in project JBM by numen06.
the class MybatisMapperRefresh method run.
@Override
public void run() {
final GlobalConfig globalConfig = GlobalConfigUtils.getGlobalConfig(configuration);
/*
* 启动 XML 热加载
*/
if (enabled) {
beforeTime = SystemClock.now();
final MybatisMapperRefresh runnable = this;
new Thread(new Runnable() {
@Override
public void run() {
if (fileSet == null) {
fileSet = new HashSet<>();
if (mapperLocations != null) {
for (Resource mapperLocation : mapperLocations) {
try {
if (ResourceUtils.isJarURL(mapperLocation.getURL())) {
String key = new UrlResource(ResourceUtils.extractJarFileURL(mapperLocation.getURL())).getFile().getPath();
fileSet.add(key);
if (jarMapper.get(key) != null) {
jarMapper.get(key).add(mapperLocation);
} else {
List<Resource> resourcesList = new ArrayList<>();
resourcesList.add(mapperLocation);
jarMapper.put(key, resourcesList);
}
} else {
fileSet.add(mapperLocation.getFile().getPath());
}
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
}
}
try {
Thread.sleep(delaySeconds * 1000);
} catch (InterruptedException interruptedException) {
interruptedException.printStackTrace();
}
do {
try {
for (String filePath : fileSet) {
File file = new File(filePath);
if (file.isFile() && file.lastModified() > beforeTime) {
List<Resource> removeList = jarMapper.get(filePath);
if (removeList != null && !removeList.isEmpty()) {
for (Resource resource : removeList) {
runnable.refresh(resource);
}
} else {
runnable.refresh(new FileSystemResource(file));
}
}
}
} catch (Exception exception) {
exception.printStackTrace();
}
try {
Thread.sleep(sleepSeconds * 1000);
} catch (InterruptedException interruptedException) {
interruptedException.printStackTrace();
}
} while (true);
}
}, "mybatis-plus MapperRefresh").start();
}
}
use of com.baomidou.mybatisplus.core.config.GlobalConfig in project springboot-templet-start by thedestiny.
the class MybatisPlusConfigSecondDatasource method secSqlSessionFactory.
// sec
@Bean("secSqlSessionFactory")
public SqlSessionFactory secSqlSessionFactory(@Qualifier("secDatasource") DataSource dataSource) throws Exception {
MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
sqlSessionFactory.setDataSource(dataSource);
MybatisConfiguration configuration = new MybatisConfiguration();
configuration.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setMapUnderscoreToCamelCase(true);
configuration.setCacheEnabled(false);
sqlSessionFactory.setConfiguration(configuration);
sqlSessionFactory.setTypeAliasesPackage("com.destiny.hiootamus.entity.second");
sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/second/*.xml"));
sqlSessionFactory.setPlugins(plusInterceptor);
sqlSessionFactory.setGlobalConfig(new GlobalConfig().setBanner(false));
return sqlSessionFactory.getObject();
}
use of com.baomidou.mybatisplus.core.config.GlobalConfig in project poseidon by muggle0.
the class MybatisPlusConfig method globalConfiguration.
// mybatis plus 全局配置
@Bean(name = "globalConfig")
public GlobalConfig globalConfiguration() {
log.info("初始化GlobalConfiguration");
GlobalConfig config = new GlobalConfig();
// 控制台打印 plus banner
config.setBanner(false);
return config;
}
Aggregations