Remove freemarkerConfiguration bean

Remove `freemarkerConfiguration` from the FreeMarkerAutoConfiguration
since it should not be needed for most applications.

The previous code also caused problems since it included a
@ConditionalOnBean annotation on a bean that was created in the same
configuration.
pull/768/head
Phillip Webb 11 years ago
parent 2fe256a8aa
commit 4248665fcd

@ -25,7 +25,6 @@ import javax.servlet.Servlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWebApplication;
@ -42,7 +41,6 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean;
import org.springframework.util.Assert;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
@ -145,14 +143,6 @@ public class FreeMarkerAutoConfiguration implements EnvironmentAware {
return freeMarkerConfigurer;
}
@Bean
@ConditionalOnBean(FreeMarkerConfigurer.class)
@ConditionalOnMissingBean
public freemarker.template.Configuration freemarkerConfiguration(
FreeMarkerConfig configurer) {
return configurer.getConfiguration();
}
@Bean
@ConditionalOnMissingBean(name = "freeMarkerViewResolver")
public FreeMarkerViewResolver freeMarkerViewResolver() {

@ -191,10 +191,10 @@ public class FreeMarkerAutoConfigurationTests {
public void renderTemplate() throws Exception {
this.context.register(FreeMarkerAutoConfiguration.class);
this.context.refresh();
freemarker.template.Configuration freemarker = this.context
.getBean(freemarker.template.Configuration.class);
FreeMarkerConfigurer freemarker = this.context
.getBean(FreeMarkerConfigurer.class);
StringWriter writer = new StringWriter();
freemarker.getTemplate("message.ftl").process(this, writer);
freemarker.getConfiguration().getTemplate("message.ftl").process(this, writer);
assertTrue("Wrong content: " + writer, writer.toString().contains("Hello World"));
}

Loading…
Cancel
Save