adm/app 계정 관련 하이버네이트 대응
This commit is contained in:
@@ -14,5 +14,6 @@ public class EmsDatasourceProperties {
|
|||||||
private String password;
|
private String password;
|
||||||
private String databaseName;
|
private String databaseName;
|
||||||
private String serverName;
|
private String serverName;
|
||||||
|
private String schema;
|
||||||
private int portNumber;
|
private int portNumber;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,5 +14,6 @@ public class GatewayDataSourceProperties {
|
|||||||
private String password;
|
private String password;
|
||||||
private String databaseName;
|
private String databaseName;
|
||||||
private String serverName;
|
private String serverName;
|
||||||
|
private String schema;
|
||||||
private int portNumber;
|
private int portNumber;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ package com.eactive.apim.portal.config;
|
|||||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
|
import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
|
||||||
@@ -19,36 +24,71 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
|||||||
repositoryBaseClass = BaseRepositoryImpl.class,
|
repositoryBaseClass = BaseRepositoryImpl.class,
|
||||||
entityManagerFactoryRef = "gatewayEntityManagerFactory")
|
entityManagerFactoryRef = "gatewayEntityManagerFactory")
|
||||||
@EnableJpaAuditing(auditorAwareRef = "auditorProvider")
|
@EnableJpaAuditing(auditorAwareRef = "auditorProvider")
|
||||||
|
@Slf4j
|
||||||
public class PortalConfigGatewayDatasource {
|
public class PortalConfigGatewayDatasource {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GatewayDataSourceProperties gatewayDataSourceProperties;
|
private GatewayDataSourceProperties gatewayDataSourceProperties;
|
||||||
|
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
if (StringUtils.isEmpty(gatewayDataSourceProperties.getSchema())) {
|
||||||
|
log.error("Profile property 'schema' is empty. Please check your configuration.");
|
||||||
|
throw new IllegalArgumentException("GatewayDataSourceProperties schema is empty. Please check your configuration.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Bean
|
||||||
|
// public DataSource gatewayDataSource() {
|
||||||
|
// AtomikosDataSourceBean dataSource = new AtomikosDataSourceBean();
|
||||||
|
// dataSource.setBeanName("gatewayDataSource");
|
||||||
|
// dataSource.setUniqueResourceName("gatewayDataSource");
|
||||||
|
// dataSource.setMinPoolSize(5);
|
||||||
|
// dataSource.setMaxPoolSize(10);
|
||||||
|
// dataSource.setMaxIdleTime(60); // seconds
|
||||||
|
// dataSource.setBorrowConnectionTimeout(30); // seconds
|
||||||
|
// dataSource.setTestQuery("SELECT 1 FROM DUAL");
|
||||||
|
// dataSource.setMaintenanceInterval(60);
|
||||||
|
// dataSource.setXaDataSourceClassName("oracle.jdbc.xa.client.OracleXADataSource");
|
||||||
|
//
|
||||||
|
// Properties xaProperties = new Properties();
|
||||||
|
// String url = String.format("jdbc:oracle:thin:@//%s:%d/%s",
|
||||||
|
// gatewayDataSourceProperties.getServerName(), // HOST
|
||||||
|
// gatewayDataSourceProperties.getPortNumber(), // PORT
|
||||||
|
// gatewayDataSourceProperties.getDatabaseName()); // SERVICE_NAME 또는 SID
|
||||||
|
// // SID를 사용하는 경우: "jdbc:oracle:thin:@host:port:SID"
|
||||||
|
//
|
||||||
|
// xaProperties.setProperty("URL", url);
|
||||||
|
// xaProperties.setProperty("user", gatewayDataSourceProperties.getUsername());
|
||||||
|
// xaProperties.setProperty("password", gatewayDataSourceProperties.getPassword());
|
||||||
|
//
|
||||||
|
// dataSource.setXaProperties(xaProperties);
|
||||||
|
// return dataSource;
|
||||||
|
// }
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public DataSource gatewayDataSource() {
|
public DataSource gatewayDataSource() {
|
||||||
AtomikosDataSourceBean dataSource = new AtomikosDataSourceBean();
|
HikariDataSource dataSource = new HikariDataSource();
|
||||||
dataSource.setBeanName("gatewayDataSource");
|
|
||||||
dataSource.setUniqueResourceName("gatewayDataSource");
|
|
||||||
dataSource.setMinPoolSize(5);
|
|
||||||
dataSource.setMaxPoolSize(10);
|
|
||||||
dataSource.setMaxIdleTime(60); // seconds
|
|
||||||
dataSource.setBorrowConnectionTimeout(30); // seconds
|
|
||||||
dataSource.setTestQuery("SELECT 1 FROM DUAL");
|
|
||||||
dataSource.setMaintenanceInterval(60);
|
|
||||||
dataSource.setXaDataSourceClassName("oracle.jdbc.xa.client.OracleXADataSource");
|
|
||||||
|
|
||||||
Properties xaProperties = new Properties();
|
|
||||||
String url = String.format("jdbc:oracle:thin:@//%s:%d/%s",
|
String url = String.format("jdbc:oracle:thin:@//%s:%d/%s",
|
||||||
gatewayDataSourceProperties.getServerName(), // HOST
|
gatewayDataSourceProperties.getServerName(), // HOST
|
||||||
gatewayDataSourceProperties.getPortNumber(), // PORT
|
gatewayDataSourceProperties.getPortNumber(), // PORT
|
||||||
gatewayDataSourceProperties.getDatabaseName()); // SERVICE_NAME 또는 SID
|
gatewayDataSourceProperties.getDatabaseName()); // SERVICE_NAME 또는 SID
|
||||||
// SID를 사용하는 경우: "jdbc:oracle:thin:@host:port:SID"
|
|
||||||
|
|
||||||
xaProperties.setProperty("URL", url);
|
dataSource.setJdbcUrl(url);
|
||||||
xaProperties.setProperty("user", gatewayDataSourceProperties.getUsername());
|
dataSource.setUsername(gatewayDataSourceProperties.getUsername());
|
||||||
xaProperties.setProperty("password", gatewayDataSourceProperties.getPassword());
|
dataSource.setPassword(gatewayDataSourceProperties.getPassword());
|
||||||
|
dataSource.setDriverClassName("oracle.jdbc.OracleDriver");
|
||||||
|
|
||||||
|
// 커넥션 풀 세팅
|
||||||
|
dataSource.setMinimumIdle(5);
|
||||||
|
dataSource.setMaximumPoolSize(10);
|
||||||
|
dataSource.setIdleTimeout(60000); // 60초
|
||||||
|
dataSource.setConnectionTimeout(30000); // 30초
|
||||||
|
dataSource.setConnectionTestQuery("SELECT 1 FROM DUAL");
|
||||||
|
|
||||||
dataSource.setXaProperties(xaProperties);
|
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +102,7 @@ public class PortalConfigGatewayDatasource {
|
|||||||
properties.put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION");
|
properties.put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION");
|
||||||
properties.put("hibernate.transaction.jta.platform", "org.hibernate.engine.transaction.jta.platform.internal.AtomikosJtaPlatform");
|
properties.put("hibernate.transaction.jta.platform", "org.hibernate.engine.transaction.jta.platform.internal.AtomikosJtaPlatform");
|
||||||
properties.put("hibernate.physical_naming_strategy", "com.eactive.apim.portal.common.entity.CustomPhysicalNamingStrategy");
|
properties.put("hibernate.physical_naming_strategy", "com.eactive.apim.portal.common.entity.CustomPhysicalNamingStrategy");
|
||||||
|
properties.put("hibernate.default_schema", gatewayDataSourceProperties.getSchema());
|
||||||
properties.put("javax.persistence.validation.mode", "none");
|
properties.put("javax.persistence.validation.mode", "none");
|
||||||
properties.put("javax.persistence.transactionType", "JTA");
|
properties.put("javax.persistence.transactionType", "JTA");
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package com.eactive.apim.portal.config;
|
package com.eactive.apim.portal.config;
|
||||||
|
|
||||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||||
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||||
import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
|
|
||||||
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
|
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -19,9 +20,7 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sungpil Hyun
|
* @author Sungpil Hyun
|
||||||
@@ -56,35 +55,59 @@ public class PortalConfigPortalDatasource {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void checkProfile() {
|
public void checkProfile() {
|
||||||
log.warn("Active profiles: {}", Arrays.toString(env.getActiveProfiles()));
|
if (StringUtils.isEmpty(emsDatasourceProperties.getSchema())) {
|
||||||
|
log.error("Profile property 'schema' is empty. Please check your configuration.");
|
||||||
|
throw new IllegalArgumentException("'ems.datasource.schema' is not configured.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Primary
|
@Primary
|
||||||
@Bean
|
@Bean
|
||||||
public DataSource portalDataSource() {
|
public DataSource portalDataSource() {
|
||||||
AtomikosDataSourceBean dataSource = new AtomikosDataSourceBean();
|
// AtomikosDataSourceBean dataSource = new AtomikosDataSourceBean();
|
||||||
dataSource.setBeanName("portalDataSource");
|
// dataSource.setBeanName("portalDataSource");
|
||||||
dataSource.setUniqueResourceName("portalDataSource");
|
// dataSource.setUniqueResourceName("portalDataSource");
|
||||||
dataSource.setMinPoolSize(5);
|
// dataSource.setMinPoolSize(5);
|
||||||
dataSource.setMaxPoolSize(10);
|
// dataSource.setMaxPoolSize(10);
|
||||||
dataSource.setMaxIdleTime(60); // seconds
|
// dataSource.setMaxIdleTime(60); // seconds
|
||||||
dataSource.setBorrowConnectionTimeout(30); // seconds
|
// dataSource.setBorrowConnectionTimeout(30); // seconds
|
||||||
dataSource.setTestQuery("SELECT 1 FROM DUAL");
|
// dataSource.setTestQuery("SELECT 1 FROM DUAL");
|
||||||
dataSource.setMaintenanceInterval(60);
|
// dataSource.setMaintenanceInterval(60);
|
||||||
dataSource.setXaDataSourceClassName("oracle.jdbc.xa.client.OracleXADataSource");
|
// dataSource.setXaDataSourceClassName("oracle.jdbc.xa.client.OracleXADataSource");
|
||||||
|
//
|
||||||
|
// Properties xaProperties = new Properties();
|
||||||
|
// String url = String.format("jdbc:oracle:thin:@//%s:%d/%s",
|
||||||
|
// emsDatasourceProperties.getServerName(), // HOST
|
||||||
|
// emsDatasourceProperties.getPortNumber(), // PORT
|
||||||
|
// emsDatasourceProperties.getDatabaseName()); // SERVICE_NAME 또는 SID
|
||||||
|
// // SID를 사용하는 경우: "jdbc:oracle:thin:@host:port:SID"
|
||||||
|
//
|
||||||
|
// xaProperties.setProperty("URL", url);
|
||||||
|
// xaProperties.setProperty("user", emsDatasourceProperties.getUsername());
|
||||||
|
// xaProperties.setProperty("password", emsDatasourceProperties.getPassword());
|
||||||
|
//
|
||||||
|
// dataSource.setXaProperties(xaProperties);
|
||||||
|
// return dataSource;
|
||||||
|
|
||||||
|
HikariDataSource dataSource = new HikariDataSource();
|
||||||
|
|
||||||
Properties xaProperties = new Properties();
|
|
||||||
String url = String.format("jdbc:oracle:thin:@//%s:%d/%s",
|
String url = String.format("jdbc:oracle:thin:@//%s:%d/%s",
|
||||||
emsDatasourceProperties.getServerName(), // HOST
|
emsDatasourceProperties.getServerName(), // HOST
|
||||||
emsDatasourceProperties.getPortNumber(), // PORT
|
emsDatasourceProperties.getPortNumber(), // PORT
|
||||||
emsDatasourceProperties.getDatabaseName()); // SERVICE_NAME 또는 SID
|
emsDatasourceProperties.getDatabaseName()); // SERVICE_NAME 또는 SID
|
||||||
// SID를 사용하는 경우: "jdbc:oracle:thin:@host:port:SID"
|
|
||||||
|
|
||||||
xaProperties.setProperty("URL", url);
|
dataSource.setJdbcUrl(url);
|
||||||
xaProperties.setProperty("user", emsDatasourceProperties.getUsername());
|
dataSource.setUsername(emsDatasourceProperties.getUsername());
|
||||||
xaProperties.setProperty("password", emsDatasourceProperties.getPassword());
|
dataSource.setPassword(emsDatasourceProperties.getPassword());
|
||||||
|
dataSource.setDriverClassName("oracle.jdbc.OracleDriver");
|
||||||
|
|
||||||
|
// 커넥션 풀 설정
|
||||||
|
dataSource.setMinimumIdle(5);
|
||||||
|
dataSource.setMaximumPoolSize(10);
|
||||||
|
dataSource.setIdleTimeout(60000); // 60s
|
||||||
|
dataSource.setConnectionTimeout(30000); // 30s
|
||||||
|
dataSource.setConnectionTestQuery("SELECT 1 FROM DUAL");
|
||||||
|
|
||||||
dataSource.setXaProperties(xaProperties);
|
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +129,7 @@ public class PortalConfigPortalDatasource {
|
|||||||
properties.put("hibernate.show_sql", "true");
|
properties.put("hibernate.show_sql", "true");
|
||||||
properties.put("hibernate.transaction.jta.platform", "org.hibernate.engine.transaction.jta.platform.internal.AtomikosJtaPlatform");
|
properties.put("hibernate.transaction.jta.platform", "org.hibernate.engine.transaction.jta.platform.internal.AtomikosJtaPlatform");
|
||||||
properties.put("hibernate.use_sql_comments", "true");
|
properties.put("hibernate.use_sql_comments", "true");
|
||||||
|
properties.put("hibernate.default_schema", emsDatasourceProperties.getSchema());
|
||||||
properties.put("javax.persistence.validation.mode", "none");
|
properties.put("javax.persistence.validation.mode", "none");
|
||||||
properties.put("javax.persistence.transactionType", "JTA");
|
properties.put("javax.persistence.transactionType", "JTA");
|
||||||
|
|
||||||
|
|||||||
@@ -20,16 +20,18 @@ ems:
|
|||||||
serverName: 192.168.240.177
|
serverName: 192.168.240.177
|
||||||
portNumber: 1599
|
portNumber: 1599
|
||||||
databaseName: DAPM
|
databaseName: DAPM
|
||||||
username: EMSADM
|
username: EMSAPP
|
||||||
password: EMSADM123!
|
password: EMSAPP123!
|
||||||
|
schema: EMSADM
|
||||||
|
|
||||||
gateway:
|
gateway:
|
||||||
datasource:
|
datasource:
|
||||||
serverName: 192.168.240.177
|
serverName: 192.168.240.177
|
||||||
portNumber: 1599
|
portNumber: 1599
|
||||||
databaseName: DAPM
|
databaseName: DAPM
|
||||||
username: AGWADM
|
username: AGWAPP
|
||||||
password: AGWADM123!
|
password: AGWAPP123!
|
||||||
|
schema: AGWADM
|
||||||
|
|
||||||
|
|
||||||
proxy:
|
proxy:
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ ems:
|
|||||||
databaseName: DAPM
|
databaseName: DAPM
|
||||||
username: EMSAPP
|
username: EMSAPP
|
||||||
password: EMSAPP123!
|
password: EMSAPP123!
|
||||||
|
schema: EMSADM
|
||||||
|
|
||||||
gateway:
|
gateway:
|
||||||
datasource:
|
datasource:
|
||||||
@@ -30,6 +31,7 @@ gateway:
|
|||||||
databaseName: DAPM
|
databaseName: DAPM
|
||||||
username: AGWAPP
|
username: AGWAPP
|
||||||
password: AGWAPP123!
|
password: AGWAPP123!
|
||||||
|
schema: AGWADM
|
||||||
|
|
||||||
#proxy:
|
#proxy:
|
||||||
# targets:
|
# targets:
|
||||||
|
|||||||
@@ -40,6 +40,10 @@
|
|||||||
<logger name="org.apache" level="INFO" additivity="false"/>
|
<logger name="org.apache" level="INFO" additivity="false"/>
|
||||||
<logger name="sun.rmi" level="WARN" additivity="false"/>
|
<logger name="sun.rmi" level="WARN" additivity="false"/>
|
||||||
<logger name="javax" level="WARN" additivity="false"/>
|
<logger name="javax" level="WARN" additivity="false"/>
|
||||||
|
<logger name="jdk.event.security" level="WARN" additivity="false"/>
|
||||||
|
<logger name="com.zaxxer.hikari" level="INFO" additivity="false"/>
|
||||||
|
<logger name="_org.springframework.web" level="INFO" additivity="false"/>
|
||||||
|
<logger name="com.atomikos" level="INFO" additivity="false"/>
|
||||||
|
|
||||||
<root level="DEBUG">
|
<root level="DEBUG">
|
||||||
<appender-ref ref="ROLLING"/>
|
<appender-ref ref="ROLLING"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user