본문 바로가기
프로그램/JPA

context-datasource.xml 설정 파일

by cbwstar 2021. 7. 2.
728x90
반응형

/* context-datasource.xml */

멀티 DB 환경 설정 파일입니다. 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:util="http://www.springframework.org/schema/util"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc"
	xmlns:jpa="http://www.springframework.org/schema/data/jpa"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
		http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.8.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd">

     <!-- 환경설정 기본정보를 globals.properties 에서 참조하도록 propertyConfigurer 설정  -->
    <util:properties id="propertyConfigurer" location="classpath:/egovframework/egovProps/globals.properties"/>
	<context:property-placeholder properties-ref="propertyConfigurer" />
	
  
	<bean id="egov.propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath*:/egovframework/egovProps/globals.properties</value>
            </list>
        </property>
    </bean>

	<!-- DataSource --> 
	<alias name="postgreDataSource" alias="egov.postgreDataSource" />
	<alias name="tiberoDataSource" alias="egov.tiberoDataSource" />
	
	<!-- 개발 -->
	<beans profile="DEV">
	    
	    <!-- postgreSql -->
    	<bean id="postgreDataSource-Spied" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
			<property name="driverClassName" value="${Globals.postgresql.DriverClassName}"/>
			<property name="url" value="${Globals.postgresql.Url}" />
			<property name="username" value="${Globals.postgresql.UserName}"/>
			<property name="password" value="${Globals.postgresql.Password}"/>
		</bean>
	
		<bean id="postgreDataSource" class="net.sf.log4jdbc.Log4jdbcProxyDataSource">
		    <constructor-arg ref="postgreDataSource-Spied"/>
			<property name="logFormatter">
				<bean class="net.sf.log4jdbc.tools.Log4JdbcCustomFormatter">
					<property name="loggingType" value="MULTI_LINE"/>
					<property name="sqlPrefix" value="SQL   :"/>
				</bean>
			</property>
		</bean>
 
        <!-- tibero -->
		<bean id="tiberoDataSource-Spied" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
			<property name="driverClassName" value="${Globals.tibero.DriverClassName}"/>
			<property name="url" value="${Globals.tibero.Url}" />
			<property name="username" value="${Globals.tibero.UserName}"/>
			<property name="password" value="${Globals.tibero.Password}"/>
		</bean>
	
		<bean id="tiberoDataSource" class="net.sf.log4jdbc.Log4jdbcProxyDataSource">
		    <constructor-arg ref="tiberoDataSource-Spied"/>
			<property name="logFormatter">
				<bean class="net.sf.log4jdbc.tools.Log4JdbcCustomFormatter">
					<property name="loggingType" value="MULTI_LINE"/>
					<property name="sqlPrefix" value="SQL   :"/>
				</bean>
			</property>
		</bean>
	
						 
	</beans>
	
	<!-- 운영 -->
	<beans profile="RUN">
	    
	    <!-- postgreSql -->
    	<bean id="postgreDataSource-Spied" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
			<property name="driverClassName" value="${Globals.postgresql.DriverClassName}"/>
			<property name="url" value="${Globals.postgresql.Url}" />
			<property name="username" value="${Globals.postgresql.UserName}"/>
			<property name="password" value="${Globals.postgresql.Password}"/>
		</bean>
	
		<bean id="postgreDataSource" class="net.sf.log4jdbc.Log4jdbcProxyDataSource">
		    <constructor-arg ref="postgreDataSource-Spied"/>
			<property name="logFormatter">
				<bean class="net.sf.log4jdbc.tools.Log4JdbcCustomFormatter">
					<property name="loggingType" value="MULTI_LINE"/>
					<property name="sqlPrefix" value="SQL   :"/>
				</bean>
			</property>
		</bean>
 
        <!-- tibero -->
		<bean id="tiberoDataSource-Spied" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
			<property name="driverClassName" value="${Globals.tibero.DriverClassName}"/>
			<property name="url" value="${Globals.tibero.Url}" />
			<property name="username" value="${Globals.tibero.UserName}"/>
			<property name="password" value="${Globals.tibero.Password}"/>
		</bean>
	
		<bean id="tiberoDataSource" class="net.sf.log4jdbc.Log4jdbcProxyDataSource">
		    <constructor-arg ref="tiberoDataSource-Spied"/>
			<property name="logFormatter">
				<bean class="net.sf.log4jdbc.tools.Log4JdbcCustomFormatter">
					<property name="loggingType" value="MULTI_LINE"/>
					<property name="sqlPrefix" value="SQL   :"/>
				</bean>
			</property>
		</bean>
	
						 
	</beans>
	
	
   
    
</beans>

 

728x90
반응형

'프로그램 > JPA' 카테고리의 다른 글

context-nexacro.xml  (0) 2021.07.02
context-mapper.xml  (0) 2021.07.02
context-jpa-repository.xml  (0) 2021.07.02
context-hibernate.xml  (0) 2021.07.02
전자정부 소스 자동 생성 툴  (0) 2021.06.30

댓글



"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."

loading