jdbc 설정이나 log4j, message 이런거? 설정할 때 properties를 사용한다.


    <beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <beans:property name="driverClassName" value="${db.Driver}"/>
        <beans:property name="url" value="${db.Url}"/>
        <beans:property name="username" value="${db.Username}"/>
        <beans:property name="password" value="${db.Password}"/>
    </beans:bean>


${} 이런 표현식을 사용하여 properties파일의 데이터를 읽어 올수 있다.




db.properties 파일에 설정 정보가 저장되어 있다.

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test
jdbc.username=root
jdbc.password=1234


이 데이터를 읽기 위해선 PropertyPlaceholderConfigurer 를 사용하여 데이터를 읽어 올 수 있다.



    <beans:bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <beans:property name="location">
            <beans:value>classpath:conf/jdbc.properties</beans:value>
        </beans:property>
    </beans:bean>


<context:property-placeholder location="classpath:conf/jdbc.properties"/>



블로그 이미지

532

처음 프로그래밍을 시작한 개발자들은 Hello World!를 기억 할 것이다. Hello world가 Hell World가 될 줄 몰랐던 한 개발자의 이야기. 게시글의 출처를 표기하며, 출처를 남기지 않고 펌을 하는것에 대해 법적 책임을 묻지 않습니다.

,