0

I currently have the following content under my mail-config.xml in my Spring MVC app, but I want to load this parameters from an external file placed ie in /var/etc/myconfig/mail-config.txt, is that possible?

I'm specially interested in placing the host and auth credentials for the smtp server, thanks

mail-config.xml

<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host" value="smtp.example.com" />
    <property name="port" value="25" />     
    <property name="defaultEncoding" value="UTF-8" />

    <property name="javaMailProperties">
        <props>
            <prop key="mail.mime.charset">UTF-8</prop>
        </props>
    </property>
</bean>
Joaquín L. Robles
  • 6,261
  • 10
  • 66
  • 96

1 Answers1

0

You can use @PropertySource if you went down the annotated method, otherwise there is no equivalent for XML configuration.

There are ways to hack this in a sense and here is a good example of how to achieve that:

Define Spring @PropertySource in xml and use it in Environment

Community
  • 1
  • 1
Aeseir
  • 7,754
  • 10
  • 58
  • 107