Reputation: 111
Im a newbie with Spring.
My problem is about send an email in spring with freemaker config.
My old system can send email because it use SpringTemplateLoader when load template when send mail. My new system uses FileTemplateLoader (I debuged to found out that) so it can not find a wright template email for sending mail. I just want to ask how to config the Freemarker to use SpringTemplateLoader. Please help. Thank you.
Upvotes: 1
Views: 1518
Reputation: 111
I found out the answer.
When use Freemarker with Spring framework, freemaker will have a config object is org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean and Spring has a lib spring-context-support.jar to support this.
Read the code of this list I find the property preferFileSystemAccess, its default value is true, just set it to false to use SpringTemplateLoader.
Let me example in my config:
<bean id="mailSender" class="com.aklero.idea.email.MailSender" init-method="initAllEmailSystems"/>
<bean id="mailTemplateBuilder" class="com.aklero.idea.email.MailTemplateBuilder" />
<bean id="freemarkerConfig" class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">
<property name="templateLoaderPath" value="classpath:com/aklero/idea/email/templates"/>
<property name="preferFileSystemAccess" value="false"/>
Upvotes: 1