DB 검증 profile 추가
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.eactive.apim.portal.config;
|
||||
|
||||
import com.eactive.apim.portal.spring.DatabaseSessionVerifier;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -73,7 +74,14 @@ public class PortalDatasourceConfiguration extends BaseDatasourceConfiguration {
|
||||
throw new IllegalArgumentException("DB 접속을 위한 JNDI 또는 서버 접속 정보가 설정되어 있지 않음");
|
||||
}
|
||||
|
||||
return createDataSource(emsProp);
|
||||
DataSource dataSource = createDataSource(emsProp);
|
||||
|
||||
if (env.matchesProfiles("db_check")) {
|
||||
DatabaseSessionVerifier verifier = new DatabaseSessionVerifier(dataSource);
|
||||
verifier.afterSingletonsInstantiated();
|
||||
}
|
||||
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
@Primary
|
||||
|
||||
@@ -2,17 +2,18 @@ package com.eactive.apim.portal.spring;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Configuration
|
||||
@Profile("db_check")
|
||||
//@Configuration
|
||||
//@Profile("db_check")
|
||||
@Slf4j
|
||||
public class DatabaseSessionVerifier implements SmartInitializingSingleton {
|
||||
private final DataSource emsDataSource;
|
||||
@@ -61,6 +62,8 @@ public class DatabaseSessionVerifier implements SmartInitializingSingleton {
|
||||
log.error("DB 세션 검증 실패", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
throw new RuntimeException("db_check profile end.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user