Usando el archivo de propiedades dentro del xml

I am using Spring Jdbc template and for that I have context.xml

    <property name="driverClassName" value="com.informix.jdbc.IfxDriver" />
    <property name="url"
        value="jdbc:informix-sqli://testdb:1111/dddd:informixserver=linuxdev" />
    <property name="username" value="test" />
    <property name="password" value="test" />
</bean>

As I have hard coded the values like "driverClassName" instead I want to load them from a properties file like ${test.driverName} .

Does any one know how can I do this one ?

preguntado el 08 de noviembre de 11 a las 09:11

1 Respuestas

In Spring 3 you can set property-placeholder location and use ${key} notation right away:

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

In Spring 2 (I think) you will need to introduce a propertyConfigurer bean like that:

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

respondido 08 nov., 11:13

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.