|
|
@ -7,6 +7,7 @@ import org.mybatis.spring.SqlSessionFactoryBean;
|
|
|
|
import org.mybatis.spring.SqlSessionTemplate;
|
|
|
|
import org.mybatis.spring.SqlSessionTemplate;
|
|
|
|
import org.mybatis.spring.annotation.MapperScan;
|
|
|
|
import org.mybatis.spring.annotation.MapperScan;
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
@ -36,7 +37,9 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
|
|
|
sqlSessionFactoryRef = Constants.SECONDARY_SQL_SESSION
|
|
|
|
sqlSessionFactoryRef = Constants.SECONDARY_SQL_SESSION
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public class SecondaryMybatisConfig {
|
|
|
|
public class SecondaryMybatisConfig {
|
|
|
|
static final String MYBATIS_CONFIG_FILE = "classpath:/egovframework/mapper/mapper-config.xml";
|
|
|
|
@Value("${spring.datasource.hikari.secondary.database}")
|
|
|
|
|
|
|
|
private String database;
|
|
|
|
|
|
|
|
private static final String MYBATIS_CONFIG_FILE = "classpath:/egovframework/mapper/mapper-config.xml";
|
|
|
|
|
|
|
|
|
|
|
|
@Bean(name = Constants.SECONDARY_SQL_SESSION)
|
|
|
|
@Bean(name = Constants.SECONDARY_SQL_SESSION)
|
|
|
|
public SqlSessionFactory secondarySqlSession(@Qualifier(Constants.SECONDARY_DATA_SOURCE) DataSource dataSource) throws Exception {
|
|
|
|
public SqlSessionFactory secondarySqlSession(@Qualifier(Constants.SECONDARY_DATA_SOURCE) DataSource dataSource) throws Exception {
|
|
|
@ -44,7 +47,7 @@ public class SecondaryMybatisConfig {
|
|
|
|
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
|
|
|
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
|
|
|
sessionFactory.setDataSource(dataSource);
|
|
|
|
sessionFactory.setDataSource(dataSource);
|
|
|
|
sessionFactory.setConfigLocation(resolver.getResource(MYBATIS_CONFIG_FILE));
|
|
|
|
sessionFactory.setConfigLocation(resolver.getResource(MYBATIS_CONFIG_FILE));
|
|
|
|
sessionFactory.setMapperLocations(resolver.getResources("classpath:/egovframework/mapper/**/*-oracle-mapper.xml"));
|
|
|
|
sessionFactory.setMapperLocations(resolver.getResources(String.format("classpath:/egovframework/mapper/**/*-%s-mapper.xml", database)));
|
|
|
|
return sessionFactory.getObject();
|
|
|
|
return sessionFactory.getObject();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|