org.zodiac.autoconfigure.mybatis.extension.MyBatisPluginFollowConfigurationCustomizerConfig Maven / Gradle / Ivy
package org.zodiac.autoconfigure.mybatis.extension;
import java.util.Map;
import org.apache.ibatis.session.Configuration;
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
import org.springframework.context.ApplicationContext;
import org.zodiac.commons.util.spring.Springs;
import org.zodiac.mybatis.extension.MyBatisPluginFollowCoreConfig;
import org.zodiac.mybatis.extension.SpringBootMyBatisExtension;
public class MyBatisPluginFollowConfigurationCustomizerConfig extends MyBatisPluginFollowCoreConfig {
public MyBatisPluginFollowConfigurationCustomizerConfig(ApplicationContext mainApplicationContext) {
super(mainApplicationContext);
}
@Override
protected void processConfiguration(SpringBootMyBatisExtension.Type type, Configuration configuration) {
super.processConfiguration(type, configuration);
if (type == SpringBootMyBatisExtension.Type.MYBATIS) {
try {
Map customizerMap = Springs.getBeansMap(getMainApplicationContext(), ConfigurationCustomizer.class);
if (!customizerMap.isEmpty()) {
for (ConfigurationCustomizer customizer : customizerMap.values()) {
customizer.customize(configuration);
}
}
} catch (Exception e) {
// ignore
}
}
}
}