DB 검증 profile 추가
This commit is contained in:
@@ -58,29 +58,34 @@ public class PortalDatasourceConfiguration extends BaseDatasourceConfiguration {
|
|||||||
@Primary
|
@Primary
|
||||||
@Bean
|
@Bean
|
||||||
public DataSource portalDataSource(EmsDatasourceProperty emsProp) {
|
public DataSource portalDataSource(EmsDatasourceProperty emsProp) {
|
||||||
|
DataSource dataSource = null;
|
||||||
|
|
||||||
// JNDI 이용
|
// JNDI 이용
|
||||||
if (StringUtils.isNotEmpty(emsProp.getJndiName())) {
|
if (StringUtils.isNotEmpty(emsProp.getJndiName())) {
|
||||||
try {
|
try {
|
||||||
return this.jndiLookup(emsProp.getJndiName());
|
dataSource = this.jndiLookup(emsProp.getJndiName());
|
||||||
} catch (NamingException e) {
|
} catch (NamingException e) {
|
||||||
log.warn("JNDI lookup failed.", e);
|
log.warn("JNDI lookup failed.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("개발환경을 위해 JNDI 대신 직접 DB 접속 시도");
|
if (dataSource == null) {
|
||||||
|
log.info("개발환경을 위해 JNDI 대신 직접 DB 접속 시도");
|
||||||
|
|
||||||
// JNDI 실패시 직접 접속 이용
|
// JNDI 실패시 직접 접속 이용
|
||||||
if (StringUtils.isEmpty(emsProp.getJdbcUrl())) {
|
if (StringUtils.isEmpty(emsProp.getJdbcUrl())) {
|
||||||
throw new IllegalArgumentException("DB 접속을 위한 JNDI 또는 서버 접속 정보가 설정되어 있지 않음");
|
throw new IllegalArgumentException("DB 접속을 위한 JNDI 또는 서버 접속 정보가 설정되어 있지 않음");
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSource = createDataSource(emsProp);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataSource dataSource = createDataSource(emsProp);
|
if (dataSource != null && env.matchesProfiles("db_check")) {
|
||||||
|
|
||||||
if (env.matchesProfiles("db_check")) {
|
|
||||||
DatabaseSessionVerifier verifier = new DatabaseSessionVerifier(dataSource);
|
DatabaseSessionVerifier verifier = new DatabaseSessionVerifier(dataSource);
|
||||||
verifier.afterSingletonsInstantiated();
|
verifier.afterSingletonsInstantiated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user