● Spring2.5에서 설정 프로퍼티 적용할때
<context:property-placeholder location="***" /> 태그를 사용
예)
system.properies
###########################################################
# properties 적용 테스트
###########################################################
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@123.140.245.3:1521:MASATO
jdbc.username=oracle
jdbc.password=wjdqh*
jdbc.initialSize=1
jdbc.maxActive=10
jdbc.maxIdle=10
# properties 적용 테스트
###########################################################
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@123.140.245.3:1521:MASATO
jdbc.username=oracle
jdbc.password=wjdqh*
jdbc.initialSize=1
jdbc.maxActive=10
jdbc.maxIdle=10
위의 property 파일을 spring에 설정 파일에서 적용 한다면
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<description>system</description>
<context:component-scan base-package="kr.forhuman.core.web.page" />
<context:property-placeholder location="classpath:system.properties"/>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<description>system</description>
<context:component-scan base-package="kr.forhuman.core.web.page" />
<context:property-placeholder location="classpath:system.properties"/>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName"><value>${jdbc.driverClassName}</value></property>
<property name="url"><value>${jdbc.url}</value></property>
<property name="username"><value>${jdbc.username}</value></property>
<property name="password"><value>${jdbc.password}</value></property>
<property name="initialSize"><value>${jdbc.initialSize}</value></property>
<property name="maxActive"><value>${jdbc.maxActive}</value></property>
<property name="maxIdle"><value>${jdbc.maxIdle}</value></property>
</bean>
.............
<property name="driverClassName"><value>${jdbc.driverClassName}</value></property>
<property name="url"><value>${jdbc.url}</value></property>
<property name="username"><value>${jdbc.username}</value></property>
<property name="password"><value>${jdbc.password}</value></property>
<property name="initialSize"><value>${jdbc.initialSize}</value></property>
<property name="maxActive"><value>${jdbc.maxActive}</value></property>
<property name="maxIdle"><value>${jdbc.maxIdle}</value></property>
</bean>
.............
적용할 프로퍼티 파일이 여러개 일 경우
<context:property-placeholder location="classpath:system.properties,classpath:system2.properties"/>
'일거리 > framework' 카테고리의 다른 글
[Spring2.5] @Controller, @RequestMapping 사용해보자 (0) | 2009.03.19 |
---|