mercredi 18 mars 2015

Spring-boot: Configure FreeMarkerConfigurationFactoryBean in web application

I'm trying to use Freemarker for e-mail templating in a web application.


I have declared a FreeMarkerConfigurationFactoryBean as follow:



@Bean
public FreeMarkerConfigurationFactoryBean freeMarkerConfigurationFactoryBean(EmailTemplateService templateService) {
FreeMarkerConfigurationFactoryBean configurationFactoryBean = new FreeMarkerConfigurationFactoryBean();
configurationFactoryBean.setPreTemplateLoaders(templateService);
return configurationFactoryBean;
}


When running my JUnit everything is working well, but when running in my webapp my bean is "overriden" by the spring boot FreeMarkerAutoConfiguration.


I have tried to:



  1. remove the spring-boot-starter-freemarker from my gradle file

  2. @EnableAutoConfiguration(exclude = {FreeMarkerAutoConfigurationk.class})

  3. spring.freemarker.enabled=false


But without success. Any idea?


Thanks guys.


Aucun commentaire:

Enregistrer un commentaire