|
|
@ -1,55 +1,31 @@
|
|
|
|
package kr.xit.core.spring.config.support;
|
|
|
|
package kr.xit.core.spring.config.support;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
import kr.xit.core.consts.Constants;
|
|
|
|
import kr.xit.core.consts.Constants;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
|
|
|
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.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
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;
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Primary;
|
|
|
|
|
|
|
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
|
|
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
|
|
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
|
|
|
|
|
|
import org.springframework.jdbc.support.lob.DefaultLobHandler;
|
|
|
|
|
|
|
|
import org.springframework.transaction.PlatformTransactionManager;
|
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//FIXME :: 재설정이 필요한 경우 해당프로젝트에 동일한 파일로 재정의 하여 사용
|
|
|
|
//FIXME :: 재설정이 필요한 경우 해당프로젝트에 동일한 파일로 재정의 하여 사용
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* <pre>
|
|
|
|
|
|
|
|
* description : Mybatis 설정 - FIXME:: @DependsOn(value = {"dataSource"}) loading
|
|
|
|
|
|
|
|
* - 조건 : @DependsOn(value = {"dataSource"})
|
|
|
|
|
|
|
|
* packageName : kr.xit.core.spring.config.support
|
|
|
|
|
|
|
|
* fileName : MybatisConfig
|
|
|
|
|
|
|
|
* author : julim
|
|
|
|
|
|
|
|
* date : 2023-04-28
|
|
|
|
|
|
|
|
* ======================================================================
|
|
|
|
|
|
|
|
* 변경일 변경자 변경 내용
|
|
|
|
|
|
|
|
* ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
* 2023-04-28 julim 최초 생성
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* </pre>
|
|
|
|
|
|
|
|
* @see DatasourceConfig
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
@Configuration
|
|
|
|
@MapperScan(
|
|
|
|
@MapperScan(
|
|
|
|
basePackages = {"kr.xit.biz.sms.mapper"},
|
|
|
|
basePackages = {"kr.xit.biz.sms.mapper"},
|
|
|
|
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";
|
|
|
|
static final String MYBATIS_CONFIG_FILE = "classpath:/egovframework/mapper/mapper-config.xml";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean(name = Constants.SECONDARY_SQL_SESSION)
|
|
|
|
@ConditionalOnProperty(value = "spring.datasource.hikari", havingValue = "oracle", matchIfMissing = false)
|
|
|
|
public SqlSessionFactory secondarySqlSession(@Qualifier(Constants.SECONDARY_DATA_SOURCE) DataSource dataSource) throws Exception {
|
|
|
|
public SqlSessionFactory secondarySqlSession(@Qualifier(Constants.SECONDARY_DATA_SOURCE) DataSource dataSource) throws Exception {
|
|
|
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
|
|
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
|
|
|
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
|
|
|
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
|
|
@ -59,6 +35,7 @@ public class SecondaryMybatisConfig {
|
|
|
|
return sessionFactory.getObject();
|
|
|
|
return sessionFactory.getObject();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ConditionalOnProperty(value = "spring.datasource.hikari", havingValue = "oracle", matchIfMissing = false)
|
|
|
|
@Bean(name = "secondarySqlSessionTemplate")
|
|
|
|
@Bean(name = "secondarySqlSessionTemplate")
|
|
|
|
public SqlSessionTemplate secondarySqlSessionTemplate(@Qualifier(Constants.SECONDARY_SQL_SESSION) SqlSessionFactory sqlSessionFactory) {
|
|
|
|
public SqlSessionTemplate secondarySqlSessionTemplate(@Qualifier(Constants.SECONDARY_SQL_SESSION) SqlSessionFactory sqlSessionFactory) {
|
|
|
|
return new SqlSessionTemplate(sqlSessionFactory);
|
|
|
|
return new SqlSessionTemplate(sqlSessionFactory);
|
|
|
|