From 7d41f18429a4039abebf75fbaa276bfdb9064a24 Mon Sep 17 00:00:00 2001 From: Rinjae Date: Fri, 12 Sep 2025 14:46:15 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A9=80=ED=8B=B0=ED=83=9C=EB=84=8C=EC=8A=A4?= =?UTF-8?q?=20=EB=8F=99=EC=9E=91=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebContent/WEB-INF/applicationContext-jpa.xml | 8 -------- .../WEB-INF/{web-default.xml => web.xml} | 0 build.gradle | 19 +++++++++--------- readme.md | 8 ++++++++ .../data/config/EMSTenantConfiguration.java | 20 +++++++++++++++++-- 5 files changed, 35 insertions(+), 20 deletions(-) rename WebContent/WEB-INF/{web-default.xml => web.xml} (100%) diff --git a/WebContent/WEB-INF/applicationContext-jpa.xml b/WebContent/WEB-INF/applicationContext-jpa.xml index a56d6c8..287b55e 100644 --- a/WebContent/WEB-INF/applicationContext-jpa.xml +++ b/WebContent/WEB-INF/applicationContext-jpa.xml @@ -113,13 +113,5 @@ false false - - SCHEMA - - com.eactive.eai.rms.data.config.ConfigurableMultiTenantConnectionProvider - - - com.eactive.eai.rms.data.config.TenantIdentifierResolver - \ No newline at end of file diff --git a/WebContent/WEB-INF/web-default.xml b/WebContent/WEB-INF/web.xml similarity index 100% rename from WebContent/WEB-INF/web-default.xml rename to WebContent/WEB-INF/web.xml diff --git a/build.gradle b/build.gradle index b8e9034..133fa55 100644 --- a/build.gradle +++ b/build.gradle @@ -47,20 +47,19 @@ compileJava { } war { - def profile = project.findProperty("profile") ?: "weblogic" - - if (profile == "weblogic") { - webXml = file("WebContent/WEB-INF/weblogic-web.xml") - } else { - webXml = file("WebContent/WEB-INF/web.xml") - } - - + def profile = project.findProperty("profile") ?: "tomcat" + + 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' } diff --git a/readme.md b/readme.md index bdfffa8..2ab5794 100644 --- a/readme.md +++ b/readme.md @@ -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 이슈) \ No newline at end of file diff --git a/src/main/java/com/eactive/eai/rms/data/config/EMSTenantConfiguration.java b/src/main/java/com/eactive/eai/rms/data/config/EMSTenantConfiguration.java index 06bbb2f..b25ec18 100644 --- a/src/main/java/com/eactive/eai/rms/data/config/EMSTenantConfiguration.java +++ b/src/main/java/com/eactive/eai/rms/data/config/EMSTenantConfiguration.java @@ -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; @@ -31,13 +36,17 @@ public class EMSTenantConfiguration { public LocalContainerEntityManagerFactoryBean entityManagerFactoryForEMS( @Qualifier(DataSourceTypeManager.MONITORING) DataSource dataSource, @Qualifier("hibernateProperties") Properties hibernateProperties) { - + LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean(); 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 settings = new HashMap<>(); + settings.put(AvailableSettings.DEFAULT_SCHEMA, System.getProperty(Keys.TABLE_OWNER_KEY)); + bean.setJpaPropertyMap(settings); + return bean; } @@ -49,5 +58,12 @@ public class EMSTenantConfiguration { jpaTransactionManager.setEntityManagerFactory(entityManagerFactory); return jpaTransactionManager; } + + @Bean("entityManagerForEMS") + public SharedEntityManagerBean entityManager(@Qualifier("entityManagerFactoryForEMS") EntityManagerFactory entityManagerFactory) { + SharedEntityManagerBean sharedEntityManagerBean = new SharedEntityManagerBean(); + sharedEntityManagerBean.setEntityManagerFactory(entityManagerFactory); + return sharedEntityManagerBean; + } }