Merge branch 'main_config_feat'

dev
gitea-관리자 1 year ago
commit 302eb02593

@ -41,7 +41,7 @@ import javax.sql.DataSource;
public class DatasourceConfig {
@Bean(name = "primaryHikariConfig")
@Primary
@ConfigurationProperties(prefix = "spring.datasource.hikari.maria")
@ConfigurationProperties(prefix = "spring.datasource.hikari.primary")
public HikariConfig primaryHikariConfig() {
// HikariConfig hikariConfig = new HikariConfig("spring.datasource.hikari");
// hikariConfig.setAutoCommit(false);

@ -5,7 +5,7 @@ spring:
datasource:
hikari:
# 9 server
maria:
primary:
driver-class-name: org.mariadb.jdbc.Driver
jdbc-url: jdbc:mariadb://211.119.124.9:4407/mens?useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&autoReconnect=true
username: root

@ -1,6 +1,7 @@
package kr.xit.biz.ens.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import io.swagger.v3.oas.annotations.media.Schema;
@ -841,7 +842,8 @@ public class EnsDTO {
*
*/
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonFormat(pattern = "yyyy-MM-dd kk:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd kk:mm:ss.SSS")
@JsonIgnore
private LocalDateTime registDt;
/**
*

@ -1,47 +1,44 @@
package kr.xit.core.spring.config.support;
package kr.xit.core.spring.config.db;
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.autoconfigure.condition.ConditionalOnProperty;
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
* description : Datasource - spring.datasource.hikari.primary
* - : spring.datasource.hikari.primary.username
*
* LazyConnectionDataSourceProxy
* Datasource
* - Spring get
* - ehcache, hibernate 1 get
* - multi-datasource datasource
* packageName : kr.xit.core.spring.config.support
* fileName : DatasourceConfig
* packageName : kr.xit.core.spring.config.db
* fileName : PrimaryDatasourceConfig
* author : julim
* date : 2023-04-28
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-04-28 julim
* 2023-10-30 julim dynamic
*
* </pre>
* @see PrimaryMybatisConfig
*/
//@ConditionalOnProperty(value = "spring", havingValue = "datasource", matchIfMissing = false)
@Slf4j
@Configuration
public class DatasourceConfig {
@ConditionalOnProperty(value = "spring.datasource.hikari.primary.username")
public class PrimaryDatasourceConfig {
@Bean(name = "primaryHikariConfig")
@Primary
@ConfigurationProperties(prefix = "spring.datasource.hikari.maria")
@ConfigurationProperties(prefix = "spring.datasource.hikari.primary")
public HikariConfig primaryHikariConfig() {
// HikariConfig hikariConfig = new HikariConfig("spring.datasource.hikari");
// hikariConfig.setAutoCommit(false);
@ -51,23 +48,8 @@ public class DatasourceConfig {
@Bean(Constants.PRIMARY_DATA_SOURCE)
@Primary
public DataSource primaryDataSource() throws Exception{
public DataSource primaryDataSource() {
//return new LazyConnectionDataSourceProxy(new HikariDataSource(primaryHikariConfig()));
return new HikariDataSource(primaryHikariConfig());
}
@Bean(name = "secondaryHikariConfig")
@ConfigurationProperties(prefix = "spring.datasource.hikari.oracle")
public HikariConfig secondaryHikariConfig() {
// HikariConfig hikariConfig = new HikariConfig("spring.datasource.hikari");
// hikariConfig.setAutoCommit(false);
// return hikariConfig;
return new HikariConfig();
}
@Bean(name = Constants.SECONDARY_DATA_SOURCE)
public DataSource secondaryDataSource() throws Exception{
//return new LazyConnectionDataSourceProxy(new HikariDataSource(secondaryHikariConfig()));
return new HikariDataSource(secondaryHikariConfig());
}
}

@ -1,41 +1,40 @@
package kr.xit.core.spring.config.support;
package kr.xit.core.spring.config.db;
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.context.annotation.*;
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 :: 재설정이 필요한 경우 해당프로젝트에 동일한 파일로 재정의 하여 사용
/**
* <pre>
* description : Mybatis - FIXME:: @DependsOn(value = {"dataSource"}) loading
* - : @DependsOn(value = {"dataSource"})
* packageName : kr.xit.core.spring.config.support
* fileName : MybatisConfig
* description : Mybatis - spring.datasource.hikari.primary
* - : spring.datasource.hikari.primary.username loading
* packageName : kr.xit.core.spring.config.db
* fileName : PrimaryMybatisConfig
* author : julim
* date : 2023-04-28
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-04-28 julim
* 2023-10-30 julim dynamic
*
* </pre>
* @see DatasourceConfig
* @see PrimaryDatasourceConfig
*/
@Slf4j
@Configuration
@ConditionalOnProperty(value = "spring.datasource.hikari.primary.username")
@MapperScan(
basePackages = {
"kr.xit.core.**.mapper",

@ -0,0 +1,52 @@
package kr.xit.core.spring.config.db;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import javax.sql.DataSource;
import kr.xit.core.consts.Constants;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* <pre>
* description : Datasource - spring.datasource.hikari.secondary
* - : spring.datasource.hikari.secondary.username
*
* LazyConnectionDataSourceProxy
* Datasource
* - Spring get
* - ehcache, hibernate 1 get
* - multi-datasource datasource
* packageName : kr.xit.core.spring.config.db
* fileName : SecondaryMybatisConfig
* author : julim
* date : 2023-04-28
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-04-28 julim
* 2023-10-30 julim dynamic
*
* </pre>
* @see SecondaryMybatisConfig
*/
@Configuration
@ConditionalOnProperty(value = "spring.datasource.hikari.secondary.username")
public class SecondaryDatasourceConfig {
@Bean(name = "secondaryHikariConfig")
@ConfigurationProperties(prefix = "spring.datasource.hikari.secondary")
public HikariConfig secondaryHikariConfig() {
// HikariConfig hikariConfig = new HikariConfig("spring.datasource.hikari");
// hikariConfig.setAutoCommit(false);
// return hikariConfig;
return new HikariConfig();
}
@Bean(name = Constants.SECONDARY_DATA_SOURCE)
public DataSource secondaryDataSource() {
//return new LazyConnectionDataSourceProxy(new HikariDataSource(secondaryHikariConfig()));
return new HikariDataSource(secondaryHikariConfig());
}
}

@ -1,54 +1,43 @@
package kr.xit.core.spring.config.support;
package kr.xit.core.spring.config.db;
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 :: 재설정이 필요한 경우 해당프로젝트에 동일한 파일로 재정의 하여 사용
/**
* <pre>
* description : Mybatis - FIXME:: @DependsOn(value = {"dataSource"}) loading
* - : @DependsOn(value = {"dataSource"})
* packageName : kr.xit.core.spring.config.support
* fileName : MybatisConfig
* description : Mybatis - spring.datasource.hikari.secondary
* - : spring.datasource.hikari.secondary.username loading
* packageName : kr.xit.core.spring.config.db
* fileName : SecondaryMybatisConfig
* author : julim
* date : 2023-04-28
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-04-28 julim
* 2023-10-30 julim dynamic
*
* </pre>
* @see DatasourceConfig
* @see SecondaryDatasourceConfig
*/
@Slf4j
@Configuration
@ConditionalOnProperty(value = "spring.datasource.hikari.secondary.username")
@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)
public SqlSessionFactory secondarySqlSession(@Qualifier(Constants.SECONDARY_DATA_SOURCE) DataSource dataSource) throws Exception {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
@ -59,6 +48,7 @@ public class SecondaryMybatisConfig {
return sessionFactory.getObject();
}
//@ConditionalOnProperty(value = "spring.datasource.hikari.secondary")
@Bean(name = "secondarySqlSessionTemplate")
public SqlSessionTemplate secondarySqlSessionTemplate(@Qualifier(Constants.SECONDARY_SQL_SESSION) SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory);

@ -1,8 +1,10 @@
package kr.xit.core.spring.config.support;
package kr.xit.core.spring.config.db;
import javax.sql.DataSource;
import kr.xit.core.consts.Constants;
import lombok.extern.slf4j.Slf4j;
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.Primary;
@ -11,15 +13,13 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
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
* description : Mybatis
* - single DB or multi DB transaction
* packageName : kr.xit.core.spring.config.db
* fileName : MybatisConfig
* author : julim
* date : 2023-04-28
@ -27,33 +27,49 @@ import javax.sql.DataSource;
*
* ----------------------------------------------------------------------
* 2023-04-28 julim
* 2023-10-30 julim dynamic
*
* </pre>
* @see DatasourceConfig
* @see PrimaryDatasourceConfig
* @see SecondaryMybatisConfig
*/
@Slf4j
@Configuration
@EnableTransactionManagement
public class TransactionConfig {
/**
* primary DB
* @param ds DataSource
* @return PlatformTransactionManager
*/
@ConditionalOnMissingBean(SecondaryMybatisConfig.class)
@Primary
@Bean
public PlatformTransactionManager primaryTransactionManager(@Qualifier(Constants.PRIMARY_DATA_SOURCE)DataSource ds) {
DataSourceTransactionManager dstm = new DataSourceTransactionManager(ds);
dstm.setGlobalRollbackOnParticipationFailure(false);
return dstm;
}
////////////////////////////////////////////////////////////////////////////////////////////
// ChainedTransactionManager : trsnsaction binding
///////////////////////////////////////////////////////////////////////////////////////////
/**
* mariaDB & oracleDB Transaction binding
* @param mariaDS Maria DataSource
* @param oracleDS Oracle DataSource
* primary DB & secondary DB Transaction binding
* @param primaryDS primary DataSource
* @param secondaryDS secondary DataSource
* @return PlatformTransactionManager
* @throws Exception Exception
*/
@ConditionalOnProperty(value = "spring.datasource.hikari.secondary.username")
@Primary
@Bean
public PlatformTransactionManager transactionManager(@Qualifier(Constants.PRIMARY_DATA_SOURCE)DataSource mariaDS,
@Qualifier(Constants.SECONDARY_DATA_SOURCE)DataSource oracleDS) {
DataSourceTransactionManager mariaTm = new DataSourceTransactionManager(mariaDS);
public PlatformTransactionManager transactionManager(@Qualifier(Constants.PRIMARY_DATA_SOURCE)DataSource primaryDS,
@Qualifier(Constants.SECONDARY_DATA_SOURCE) DataSource secondaryDS) {
DataSourceTransactionManager mariaTm = new DataSourceTransactionManager(primaryDS);
mariaTm.setGlobalRollbackOnParticipationFailure(false);
mariaTm.setNestedTransactionAllowed(true);
DataSourceTransactionManager oracleTm = new DataSourceTransactionManager(oracleDS);
DataSourceTransactionManager oracleTm = new DataSourceTransactionManager(secondaryDS);
oracleTm.setGlobalRollbackOnParticipationFailure(false);
oracleTm.setNestedTransactionAllowed(true);

@ -0,0 +1,3 @@
#org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
# kr.xit.core.spring.auto.PrimaryDatabaseAutoConfiguration, kr.xit.core.spring.auto.SecondaryDatabaseAutoConfiguration]
#

@ -9,7 +9,7 @@ spring:
# root / xit1807
hikari:
# 9 server
maria:
primary:
driver-class-name: org.mariadb.jdbc.Driver
jdbc-url: jdbc:mariadb://211.119.124.9:4407/mens?useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&autoReconnect=true
username: root
@ -19,7 +19,7 @@ spring:
# 115 server
# jdbc:oracle:thin:@211.119.124.115:1521:XITSMS
# xit_sms_lg / xit_sms_lg
oracle:
secondary:
driver-class-name: oracle.jdbc.OracleDriver
jdbc-url: jdbc:oracle:thin:@211.119.124.115:1521:XITSMS
username: xit_sms_lg

@ -652,7 +652,7 @@
AND tesm.ffnlg_code = #{ffnlgCode}
</select>
<select id="selectSmsSendTgts" resultType="kr.xit.biz.ens.model.EnsDTO$SmsSndng">
<select id="selectSmsSendTgts2" resultType="kr.xit.biz.ens.model.EnsDTO$SmsSndng">
/** ens-mysql-mapper|selectSmsSendTgts-SMS 발송 대상 목록 조회|julim */
SELECT tesm.unity_sndng_mastr_id
, tesm.sndng_mastr_id
@ -680,6 +680,25 @@
AND tesm.ffnlg_code = #{ffnlgCode}
</select>
<select id="selectSmsSendTgts" resultType="kr.xit.biz.ens.model.EnsDTO$SmsSndng">
/** ens-mysql-mapper|selectSmsSendTgts-SMS 발송 대상 목록 조회|julim */
SELECT tess.sndng_detail_id
, tess.unity_sndng_detail_id
, tess.sndng_mastr_id
, tess.signgu_code
, tess.ffnlg_code
, tess.vhcle_no
, tess.sms_sndng_dt /* 문자 발송 일시 */
, tess.sms_trnsmis_stle /* 문자 전송 형태 */
, tess.sms_trnsmit_tlphon_no /* 문자 송신 전화 번호 */
, tess.sms_recptn_tlphon_no /* 문자 수진 전화 번호 */
, tess.sms_mssage /* 문자 메세지 */
, tess.sms_sndng_sttus /* 문자 발송 상태 */
, tess.sms_sndng_process_sttus /* 문자 발송 처리 상태 */
FROM tb_ens_sms_sndng tess
WHERE tess.sndng_mastr_id = '20230728000000000005'
</select>
<select id="selectKtBcMstTgtInfo" resultType="kr.xit.biz.ens.model.EnsKtBcDTO$KtBcMst">
/** ens-mysql-mapper|selectKtBcMstTgtInfo-Kt 본문자 수신 대상 정보 조회|julim */
SELECT tesm.sndng_mastr_id /* 발송마스터 ID */

@ -91,21 +91,21 @@ public class AppInitHelper {
String db = BouncyDecUtils.decode(p+"private_key.pem", k, env.getProperty("app.license.data2"));
String[] arrDb = db.split(";");
props.put("spring.datasource.hikari.maria.driver-class-name", arrDb[0]);
props.put("spring.datasource.hikari.maria.read-only", arrDb[4]);
props.put("spring.datasource.hikari.maria.jdbc-url", arrDb[3]);
props.put("spring.datasource.hikari.maria.username", arrDb[1]);
props.put("spring.datasource.hikari.maria.password", arrDb[2]);
props.put("spring.datasource.hikari.primary.driver-class-name", arrDb[0]);
props.put("spring.datasource.hikari.primary.read-only", arrDb[4]);
props.put("spring.datasource.hikari.primary.jdbc-url", arrDb[3]);
props.put("spring.datasource.hikari.primary.username", arrDb[1]);
props.put("spring.datasource.hikari.primary.password", arrDb[2]);
db = null;
arrDb = null;
db = BouncyDecUtils.decode(p+"private_key.pem", k, env.getProperty("app.license.data3"));
arrDb = db.split(";");
props.put("spring.datasource.hikari.oracle.driver-class-name", arrDb[0]);
props.put("spring.datasource.hikari.oracle.read-only", arrDb[4]);
props.put("spring.datasource.hikari.oracle.jdbc-url", arrDb[3]);
props.put("spring.datasource.hikari.oracle.username", arrDb[1]);
props.put("spring.datasource.hikari.oracle.password", arrDb[2]);
props.put("spring.datasource.hikari.secondary.driver-class-name", arrDb[0]);
props.put("spring.datasource.hikari.secondary.read-only", arrDb[4]);
props.put("spring.datasource.hikari.secondary.jdbc-url", arrDb[3]);
props.put("spring.datasource.hikari.secondary.username", arrDb[1]);
props.put("spring.datasource.hikari.secondary.password", arrDb[2]);
env.getPropertySources().addFirst(new PropertiesPropertySource("decodeProps", props));
}

Loading…
Cancel
Save