diff --git a/mens-batch/src/main/java/kr/xit/core/spring/config/support/DatasourceConfig.java b/mens-batch/src/main/java/kr/xit/core/spring/config/support/DatasourceConfig.java index 290867b..5ecae09 100644 --- a/mens-batch/src/main/java/kr/xit/core/spring/config/support/DatasourceConfig.java +++ b/mens-batch/src/main/java/kr/xit/core/spring/config/support/DatasourceConfig.java @@ -2,15 +2,12 @@ package kr.xit.core.spring.config.support; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; +import javax.sql.DataSource; import kr.xit.core.consts.Constants; -import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy; - -import javax.sql.DataSource; //FIXME :: 재설정이 필요한 경우 해당 프로젝트에 동일한 파일로 재정의 하여 사용 /** @@ -36,7 +33,6 @@ import javax.sql.DataSource; * @see PrimaryMybatisConfig */ //@ConditionalOnProperty(value = "spring", havingValue = "datasource", matchIfMissing = false) -@Slf4j @Configuration public class DatasourceConfig { @Bean(name = "primaryHikariConfig") @@ -56,6 +52,7 @@ public class DatasourceConfig { return new HikariDataSource(primaryHikariConfig()); } + //@ConditionalOnProperty(value = "spring.datasource.hikari", havingValue = "oracle", matchIfMissing = false) @Bean(name = "secondaryHikariConfig") @ConfigurationProperties(prefix = "spring.datasource.hikari.oracle") public HikariConfig secondaryHikariConfig() { diff --git a/mens-batch/src/main/java/kr/xit/core/spring/config/support/SecondaryMybatisConfig.java b/mens-batch/src/main/java/kr/xit/core/spring/config/support/SecondaryMybatisConfig.java index 808e8f0..18022fb 100644 --- a/mens-batch/src/main/java/kr/xit/core/spring/config/support/SecondaryMybatisConfig.java +++ b/mens-batch/src/main/java/kr/xit/core/spring/config/support/SecondaryMybatisConfig.java @@ -1,55 +1,31 @@ package kr.xit.core.spring.config.support; +import javax.sql.DataSource; import kr.xit.core.consts.Constants; -import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.annotation.MapperScan; 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.Configuration; -import org.springframework.context.annotation.Lazy; -import org.springframework.context.annotation.Primary; 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 :: 재설정이 필요한 경우 해당프로젝트에 동일한 파일로 재정의 하여 사용 -/** - *
- * 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       최초 생성
- *
- * 
- * @see DatasourceConfig - */ -@Slf4j + + @Configuration @MapperScan( basePackages = {"kr.xit.biz.sms.mapper"}, sqlSessionFactoryRef = Constants.SECONDARY_SQL_SESSION ) public class SecondaryMybatisConfig { - 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 { PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); @@ -59,6 +35,7 @@ public class SecondaryMybatisConfig { return sessionFactory.getObject(); } + @ConditionalOnProperty(value = "spring.datasource.hikari", havingValue = "oracle", matchIfMissing = false) @Bean(name = "secondarySqlSessionTemplate") public SqlSessionTemplate secondarySqlSessionTemplate(@Qualifier(Constants.SECONDARY_SQL_SESSION) SqlSessionFactory sqlSessionFactory) { return new SqlSessionTemplate(sqlSessionFactory); diff --git a/mens-batch/src/main/java/kr/xit/core/spring/config/support/TransactionConfig.java b/mens-batch/src/main/java/kr/xit/core/spring/config/support/TransactionConfig.java index 9ab3c26..2cb8e99 100644 --- a/mens-batch/src/main/java/kr/xit/core/spring/config/support/TransactionConfig.java +++ b/mens-batch/src/main/java/kr/xit/core/spring/config/support/TransactionConfig.java @@ -1,5 +1,6 @@ package kr.xit.core.spring.config.support; +import javax.sql.DataSource; import kr.xit.core.consts.Constants; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Qualifier; @@ -11,8 +12,6 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; -import javax.sql.DataSource; - //FIXME :: 재설정이 필요한 경우 해당프로젝트에 동일한 파일로 재정의 하여 사용 /** @@ -35,6 +34,15 @@ import javax.sql.DataSource; @Configuration @EnableTransactionManagement public class TransactionConfig { +// @ConditionalOnMissingBean(SecondaryMybatisConfig.class) +// @Primary +// @Bean +// public PlatformTransactionManager primaryTransactionManager(@Qualifier(Constants.PRIMARY_DATA_SOURCE)DataSource dataSource) { +// DataSourceTransactionManager dstm = new DataSourceTransactionManager(dataSource); +// dstm.setGlobalRollbackOnParticipationFailure(false); +// return dstm; +// } + //////////////////////////////////////////////////////////////////////////////////////////// // ChainedTransactionManager : trsnsaction binding /////////////////////////////////////////////////////////////////////////////////////////// @@ -45,6 +53,7 @@ public class TransactionConfig { * @return PlatformTransactionManager * @throws Exception Exception */ + //@ConditionalOnProperty(value = "spring.datasource.hikari", havingValue = "oracle", matchIfMissing = false) @Primary @Bean public PlatformTransactionManager transactionManager(@Qualifier(Constants.PRIMARY_DATA_SOURCE)DataSource mariaDS,