|
|
@ -7,6 +7,7 @@ import model.DataSourceModel; |
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
import org.apache.ibatis.session.Configuration; |
|
|
|
import org.apache.ibatis.session.Configuration; |
|
|
|
import org.mybatis.spring.SqlSessionFactoryBean; |
|
|
|
import org.mybatis.spring.SqlSessionFactoryBean; |
|
|
|
|
|
|
|
import org.mybatis.spring.SqlSessionTemplate; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
|
|
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
|
|
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
|
|
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
|
|
@ -86,6 +87,10 @@ public class MyBatisConfig extends InitConfig { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if(factoryBean.getObject()!=null){ |
|
|
|
if(factoryBean.getObject()!=null){ |
|
|
|
beanFactory.registerSingleton(dataSourceModel.getFactoryBean(), factoryBean.getObject()); |
|
|
|
beanFactory.registerSingleton(dataSourceModel.getFactoryBean(), factoryBean.getObject()); |
|
|
|
|
|
|
|
SqlSessionTemplate sqlSessionTemplate=new SqlSessionTemplate(factoryBean.getObject()); |
|
|
|
|
|
|
|
sqlSessionTemplate.getConfiguration().getMapperRegistry().getMappers().forEach(c->{ |
|
|
|
|
|
|
|
beanFactory.registerSingleton(dataSourceModel.getFactoryBean()+c.getSimpleName(),sqlSessionTemplate.getMapper(c)); |
|
|
|
|
|
|
|
}); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
LOG.error("初始化数据库配置" + JSON.toJSONString(dataSourceModel) + "失败"); |
|
|
|
LOG.error("初始化数据库配置" + JSON.toJSONString(dataSourceModel) + "失败"); |
|
|
|
} |
|
|
|
} |
|
|
|