feat: DB dynamic 설정 batch에서 mens-core 로 이동

dev
gitea-관리자 1 year ago
parent 1361549b20
commit cec6ad5d37

@ -1,58 +0,0 @@
package kr.xit.core.spring.config.support;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
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 :: 재설정이 필요한 경우 해당 프로젝트에 동일한 파일로 재정의 하여 사용
/**
* <pre>
* description : Datasource - FIXME:: spring.datasource loading
* - : spring.datasource
*
* LazyConnectionDataSourceProxy
* Datasource
* - Spring get
* - ehcache, hibernate 1 get
* - multi-datasource datasource
* packageName : kr.xit.core.spring.config.support
* fileName : DatasourceConfig
* author : julim
* date : 2023-04-28
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-04-28 julim
*
* </pre>
* @see PrimaryMybatisConfig
*/
//@ConditionalOnProperty(value = "spring", havingValue = "datasource", matchIfMissing = false)
@Slf4j
@Configuration
public class DatasourceConfig {
@Bean(name = "primaryHikariConfig")
@Primary
@ConfigurationProperties(prefix = "spring.datasource.hikari.primary")
public HikariConfig primaryHikariConfig() {
// HikariConfig hikariConfig = new HikariConfig("spring.datasource.hikari");
// hikariConfig.setAutoCommit(false);
// return hikariConfig;
return new HikariConfig();
}
@Bean(Constants.PRIMARY_DATA_SOURCE)
@Primary
public DataSource primaryDataSource() throws Exception{
//return new LazyConnectionDataSourceProxy(new HikariDataSource(primaryHikariConfig()));
return new HikariDataSource(primaryHikariConfig());
}
}

@ -1,82 +0,0 @@
package kr.xit.core.spring.config.support;
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.context.annotation.*;
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 :: 재설정이 필요한 경우 해당프로젝트에 동일한 파일로 재정의 하여 사용
/**
* <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
@MapperScan(
basePackages = {
"kr.xit.core.**.mapper",
"kr.xit.biz.**.mapper",
"kr.xit.ens.**.mapper",
},
sqlSessionFactoryRef = Constants.PRIMARY_SQL_SESSION
)
public class PrimaryMybatisConfig {
static final String MYBATIS_CONFIG_FILE = "classpath:/egovframework/mapper/mapper-config.xml";
@ConditionalOnMissingBean
@Bean
@Lazy
public DefaultLobHandler lobHandler() {
return new DefaultLobHandler();
}
@Primary
@Bean(name = Constants.PRIMARY_SQL_SESSION)
public SqlSessionFactory primarySqlSession(@Qualifier(Constants.PRIMARY_DATA_SOURCE)DataSource dataSource) throws Exception {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setConfigLocation(resolver.getResource(MYBATIS_CONFIG_FILE));
sessionFactory.setMapperLocations(resolver.getResources("classpath:/egovframework/mapper/**/*-mysql-mapper.xml"));
return sessionFactory.getObject();
}
@Primary
@Bean(name = "primarySqlSessionTemplate")
public SqlSessionTemplate primarySqlSessionTemplate(@Qualifier(Constants.PRIMARY_SQL_SESSION) SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory);
}
@Primary
@Bean
public PlatformTransactionManager primaryTransactionManager(@Qualifier(Constants.PRIMARY_DATA_SOURCE)DataSource dataSource) {
DataSourceTransactionManager dstm = new DataSourceTransactionManager(dataSource);
dstm.setGlobalRollbackOnParticipationFailure(false);
return dstm;
}
}

@ -19,12 +19,12 @@ spring:
# 115 server # 115 server
# jdbc:oracle:thin:@211.119.124.115:1521:XITSMS # jdbc:oracle:thin:@211.119.124.115:1521:XITSMS
# xit_sms_lg / xit_sms_lg # xit_sms_lg / xit_sms_lg
oracle: # oracle:
driver-class-name: oracle.jdbc.OracleDriver # driver-class-name: oracle.jdbc.OracleDriver
jdbc-url: jdbc:oracle:thin:@211.119.124.115:1521:XITSMS # jdbc-url: jdbc:oracle:thin:@211.119.124.115:1521:XITSMS
username: xit_sms_lg # username: xit_sms_lg
password: xit_sms_lg # password: xit_sms_lg
read-only: false # read-only: false
devtools: devtools:
livereload: livereload:

@ -19,12 +19,12 @@ spring:
# 115 server # 115 server
# jdbc:oracle:thin:@211.119.124.115:1521:XITSMS # jdbc:oracle:thin:@211.119.124.115:1521:XITSMS
# xit_sms_lg / xit_sms_lg # xit_sms_lg / xit_sms_lg
secondary: # secondary:
driver-class-name: oracle.jdbc.OracleDriver # driver-class-name: oracle.jdbc.OracleDriver
jdbc-url: jdbc:oracle:thin:@211.119.124.115:1521:XITSMS # jdbc-url: jdbc:oracle:thin:@211.119.124.115:1521:XITSMS
username: xit_sms_lg # username: xit_sms_lg
password: xit_sms_lg # password: xit_sms_lg
read-only: false # read-only: false
devtools: devtools:
livereload: livereload:

Loading…
Cancel
Save