diff --git a/mens-api/src/main/resources/config/application-dev.yml b/mens-api/src/main/resources/config/application-dev.yml index f7cbb33..740b74c 100644 --- a/mens-api/src/main/resources/config/application-dev.yml +++ b/mens-api/src/main/resources/config/application-dev.yml @@ -5,13 +5,17 @@ spring: datasource: hikari: # 9 server - maria: + primary: + database: mysql 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 password: xit1807 read-only: false + # multi-database + #secondary: + devtools: livereload: enabled: true diff --git a/mens-api/src/main/resources/config/application-local.yml b/mens-api/src/main/resources/config/application-local.yml index 17d50f1..8852d94 100644 --- a/mens-api/src/main/resources/config/application-local.yml +++ b/mens-api/src/main/resources/config/application-local.yml @@ -6,11 +6,14 @@ spring: hikari: # 9 server primary: + database: mysql 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 password: xit1807 read-only: false + # multi-database + #secondary: devtools: restart: diff --git a/mens-api/src/main/resources/config/application-prod.yml b/mens-api/src/main/resources/config/application-prod.yml index c9855cb..cb2d9cc 100644 --- a/mens-api/src/main/resources/config/application-prod.yml +++ b/mens-api/src/main/resources/config/application-prod.yml @@ -6,12 +6,15 @@ spring: hikari: # 9 server primary: + database: mysql driver-class-name: org.mariadb.jdbc.Driver # jdbc:mariadb://127.0.0.1:4407/mens?useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&autoReconnect=true jdbc-url: ENC(N7TRplIpBBUbXtSi8fx0wr92OdMgvp9Iw5tmaW7EUaH6ialiAWohx+rOEZx/j+OHFkJSrhYQElPIVe5r4d0tWDNREpgvKwxZRTGXhNdTMMUUHonkGKfB7bURxMfjuMSQEUdKicPZv+xB9eGlwcuPpgC7vaQuZM6WrUDP31+6qYboTUQKBK/7lg==) username: ENC(wgnjrc4VB7R3I+OwMV+iXQ==) password: ENC(+sXCmhmSV3Q/3KgOnmpnTQ==) read-only: false + # multi-database + #secondary: devtools: livereload: diff --git a/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngCloseJobScheduler.java b/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngCloseJobScheduler.java index ef78b8f..2322b48 100644 --- a/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngCloseJobScheduler.java +++ b/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngCloseJobScheduler.java @@ -15,6 +15,7 @@ import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** @@ -45,7 +46,7 @@ public class SndngCloseJobScheduler { @Value("${app.slack-webhook.enabled:false}") private String isSlackEnabled; - //@Scheduled(cron = "${app.batch.cron.ens.close}") + @Scheduled(cron = "${app.batch.cron.ens.close}") public void runJob() { Map confMap = new HashMap<>(); diff --git a/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngMakeJobScheduler.java b/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngMakeJobScheduler.java index cfeab59..b429789 100644 --- a/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngMakeJobScheduler.java +++ b/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngMakeJobScheduler.java @@ -15,6 +15,7 @@ import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** @@ -45,7 +46,7 @@ public class SndngMakeJobScheduler { @Value("${app.slack-webhook.enabled:false}") private String isSlackEnabled; - //@Scheduled(cron = "${app.batch.cron.ens.make}") + @Scheduled(cron = "${app.batch.cron.ens.make}") public void runJob() { Map confMap = new HashMap<>(); diff --git a/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngSendBulksJobScheduler.java b/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngSendBulksJobScheduler.java index 2eeec94..e913b87 100644 --- a/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngSendBulksJobScheduler.java +++ b/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngSendBulksJobScheduler.java @@ -15,6 +15,7 @@ import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** @@ -44,7 +45,7 @@ public class SndngSendBulksJobScheduler { @Value("${app.slack-webhook.enabled:false}") private String isSlackEnabled; - //@Scheduled(cron = "${app.batch.cron.ens.send}") + @Scheduled(cron = "${app.batch.cron.ens.send}") public void runJob() { Map confMap = new HashMap<>(); diff --git a/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngStatusBulksJobScheduler.java b/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngStatusBulksJobScheduler.java index a11ce39..04b0342 100644 --- a/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngStatusBulksJobScheduler.java +++ b/mens-batch/src/main/java/kr/xit/batch/ens/scheduler/SndngStatusBulksJobScheduler.java @@ -15,6 +15,7 @@ import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** @@ -44,7 +45,7 @@ public class SndngStatusBulksJobScheduler { @Value("${app.slack-webhook.enabled:false}") private String isSlackEnabled; - //@Scheduled(cron = "${app.batch.cron.ens.kko-status}") + @Scheduled(cron = "${app.batch.cron.ens.kko-status}") public void runJob() { Map confMap = new HashMap<>(); diff --git a/mens-batch/src/main/resources/config/application-dev.yml b/mens-batch/src/main/resources/config/application-dev.yml index dbf9c0f..07b73ad 100644 --- a/mens-batch/src/main/resources/config/application-dev.yml +++ b/mens-batch/src/main/resources/config/application-dev.yml @@ -10,16 +10,16 @@ spring: hikari: # 9 server maria: + database: mysql 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 password: xit1807 read-only: false - # 115 server - # jdbc:oracle:thin:@211.119.124.115:1521:XITSMS - # xit_sms_lg / xit_sms_lg -# oracle: + # multi-database +# secondary: +# database: oracle # driver-class-name: oracle.jdbc.OracleDriver # jdbc-url: jdbc:oracle:thin:@211.119.124.115:1521:XITSMS # username: xit_sms_lg diff --git a/mens-batch/src/main/resources/config/application-local.yml b/mens-batch/src/main/resources/config/application-local.yml index ae9f8d6..51ecde6 100644 --- a/mens-batch/src/main/resources/config/application-local.yml +++ b/mens-batch/src/main/resources/config/application-local.yml @@ -10,12 +10,16 @@ spring: hikari: # 9 server primary: + database: mysql 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 password: xit1807 read-only: false + # multi-database + #secondary: + # 115 server # jdbc:oracle:thin:@211.119.124.115:1521:XITSMS # xit_sms_lg / xit_sms_lg diff --git a/mens-batch/src/main/resources/config/application-prod.yml b/mens-batch/src/main/resources/config/application-prod.yml index 4e201a2..ffaf5b1 100644 --- a/mens-batch/src/main/resources/config/application-prod.yml +++ b/mens-batch/src/main/resources/config/application-prod.yml @@ -8,6 +8,7 @@ spring: hikari: # 9 server primary: + database: mysql driver-class-name: org.mariadb.jdbc.Driver # jdbc:mariadb://127.0.0.1:4407/mens?useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&autoReconnect=true jdbc-url: ENC(N7TRplIpBBUbXtSi8fx0wr92OdMgvp9Iw5tmaW7EUaH6ialiAWohx+rOEZx/j+OHFkJSrhYQElPIVe5r4d0tWDNREpgvKwxZRTGXhNdTMMUUHonkGKfB7bURxMfjuMSQEUdKicPZv+xB9eGlwcuPpgC7vaQuZM6WrUDP31+6qYboTUQKBK/7lg==) @@ -15,6 +16,9 @@ spring: password: ENC(+sXCmhmSV3Q/3KgOnmpnTQ==) read-only: false + # multi-database + #secondary: + devtools: livereload: enabled: false diff --git a/mens-core/src/main/java/kr/xit/core/spring/config/db/PrimaryMybatisConfig.java b/mens-core/src/main/java/kr/xit/core/spring/config/db/PrimaryMybatisConfig.java index 2f353a5..05f37cb 100644 --- a/mens-core/src/main/java/kr/xit/core/spring/config/db/PrimaryMybatisConfig.java +++ b/mens-core/src/main/java/kr/xit/core/spring/config/db/PrimaryMybatisConfig.java @@ -7,6 +7,7 @@ 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.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; @@ -44,8 +45,9 @@ import org.springframework.jdbc.support.lob.DefaultLobHandler; sqlSessionFactoryRef = Constants.PRIMARY_SQL_SESSION ) public class PrimaryMybatisConfig { - - static final String MYBATIS_CONFIG_FILE = "classpath:/egovframework/mapper/mapper-config.xml"; + @Value("${spring.datasource.hikari.primary.database}") + private String database; + private static final String MYBATIS_CONFIG_FILE = "classpath:/egovframework/mapper/mapper-config.xml"; @ConditionalOnMissingBean @Bean @@ -61,7 +63,7 @@ public class PrimaryMybatisConfig { 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")); + sessionFactory.setMapperLocations(resolver.getResources(String.format("classpath:/egovframework/mapper/**/*-%s-mapper.xml", database))); return sessionFactory.getObject(); } diff --git a/mens-core/src/main/java/kr/xit/core/spring/config/db/SecondaryMybatisConfig.java b/mens-core/src/main/java/kr/xit/core/spring/config/db/SecondaryMybatisConfig.java index db73dc4..50e29b9 100644 --- a/mens-core/src/main/java/kr/xit/core/spring/config/db/SecondaryMybatisConfig.java +++ b/mens-core/src/main/java/kr/xit/core/spring/config/db/SecondaryMybatisConfig.java @@ -7,6 +7,7 @@ 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.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -36,7 +37,9 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver; sqlSessionFactoryRef = Constants.SECONDARY_SQL_SESSION ) 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) public SqlSessionFactory secondarySqlSession(@Qualifier(Constants.SECONDARY_DATA_SOURCE) DataSource dataSource) throws Exception { @@ -44,7 +47,7 @@ public class SecondaryMybatisConfig { final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); sessionFactory.setDataSource(dataSource); 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(); }