Announcement Announcement Module
Collapse
No announcement yet.
Property file entries not loading Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment

    Working...
    X