Results 1 to 2 of 2

Thread: Property file entries not loading

  1. #1
    Join Date
    Feb 2009
    Posts
    5

    Default Property file entries not loading

    I would like read property file entry values in mailSender bean, some how i am not getting the ${smtp.host} value.
    Please find below my entries and let me know the problem


    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer" scope="singleton" lazy-init="false" >
    <property name="location">
    <value>classpath:smtp_config.properties</value>
    </property>
    </bean>

    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailS enderImpl" depends="propertyConfigurer">
    <property name="host"><value>${smtp.host}</value></property>
    </bean>



    smtp_config.properties file
    smtp.host=EXCH-TEST.soft-consulting.com

  2. #2
    Join Date
    Apr 2007
    Posts
    307

    Default

    Assuming you're using Spring 2.5 or better, this is how the configuration should read:

    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           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">
    <beans>
        <context:property-placeholder location="classpath:smtp_config.properties"/>
    
        <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
            <property name="host" value="${smtp.host}"/>
        </bean>
    </beans>
    If this does not work for you, please attach sample code, preferably buildable with Maven.
    Chris Beams
    Spring Framework committer, VMware
    http://github.com/cbeams

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •