멀티태넌스 동작 확인

This commit is contained in:
Rinjae
2025-09-12 14:46:15 +09:00
parent ff99e7caad
commit 7d41f18429
5 changed files with 35 additions and 20 deletions
@@ -113,13 +113,5 @@
<prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>
<prop key="hibernate.integration.envers.enabled">false</prop>
<prop key="hibernate.multiTenancy">SCHEMA</prop>
<prop key="hibernate.multi_tenant_connection_provider">
com.eactive.eai.rms.data.config.ConfigurableMultiTenantConnectionProvider
</prop>
<prop key="hibernate.tenant_identifier_resolver">
com.eactive.eai.rms.data.config.TenantIdentifierResolver
</prop>
</util:properties>
</beans>
+6 -7
View File
@@ -47,20 +47,19 @@ compileJava {
}
war {
def profile = project.findProperty("profile") ?: "weblogic"
def profile = project.findProperty("profile") ?: "tomcat"
if (profile == "weblogic") {
webXml = file("WebContent/WEB-INF/weblogic-web.xml")
} else {
webXml = file("WebContent/WEB-INF/web.xml")
}
if (profile == "weblogic") {
webXml = file("WebContent/WEB-INF/weblogic-web.xml")
}
// rootSpec.exclude '**/persistence.xml'
exclude '**/context.xml'
archiveFileName = "eapim-admin.war"
archiveFileName = "eapim-admin.war"
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
+8
View File
@@ -46,3 +46,11 @@ eLink 모듈을 참조하여 구성되어있으며, 추후 필요 모듈외에
-Dfile.encoding=utf-8
-DLOGBACK_LOG_LEVEL=info
```
### Gradle 빌드 옵션
```bash
# Weblogic 배포용 (테스트 제외)
gradle build -x test -Pprofile=weblogic
```
- -Pprofile=weblogic 사용시 weblogic-web.xml 을 web.xml 로 사용 (DefaultServlet 이슈)
@@ -1,10 +1,13 @@
package com.eactive.eai.rms.data.config;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.hibernate.cfg.AvailableSettings;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan.Filter;
@@ -13,10 +16,12 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.support.SharedEntityManagerBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.eactive.eai.common.dao.Keys;
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
import com.eactive.eai.rms.common.datasource.DataSourceTypeManager;
import com.eactive.eai.rms.data.EMSDataSource;
@@ -36,8 +41,12 @@ public class EMSTenantConfiguration {
bean.setDataSource(dataSource);
bean.setPackagesToScan("com.eactive.eai.data", "com.eactive.eai.rms.data", "com.eactive.apim.portal");
bean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
bean.setJpaProperties(hibernateProperties);
Map<String, Object> settings = new HashMap<>();
settings.put(AvailableSettings.DEFAULT_SCHEMA, System.getProperty(Keys.TABLE_OWNER_KEY));
bean.setJpaPropertyMap(settings);
return bean;
}
@@ -50,4 +59,11 @@ public class EMSTenantConfiguration {
return jpaTransactionManager;
}
@Bean("entityManagerForEMS")
public SharedEntityManagerBean entityManager(@Qualifier("entityManagerFactoryForEMS") EntityManagerFactory entityManagerFactory) {
SharedEntityManagerBean sharedEntityManagerBean = new SharedEntityManagerBean();
sharedEntityManagerBean.setEntityManagerFactory(entityManagerFactory);
return sharedEntityManagerBean;
}
}