diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java index b2f59dc714d..b48004186a3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java @@ -150,9 +150,9 @@ public class ThymeleafAutoConfiguration { @ConditionalOnMissingBean(SpringTemplateEngine.class) public SpringTemplateEngine templateEngine() { SpringTemplateEngine engine = new SpringTemplateEngine(); + engine.setEnableSpringELCompiler(this.properties.isEnableSpringElCompiler()); this.templateResolvers.forEach(engine::addTemplateResolver); this.dialects.forEach(engine::addDialect); - engine.setEnableSpringELCompiler(this.properties.isEnableSpringElCompiler()); return engine; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java index cec9353ebe5..058ab89a375 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java @@ -141,6 +141,20 @@ public class ThymeleafReactiveAutoConfigurationTests { .isEqualTo(new String[] { "foo", "bar" }); } + @Test + public void overrideEnableSpringElCompiler() { + load(BaseConfiguration.class, "spring.thymeleaf.enable-spring-el-compiler:true"); + assertThat(this.context.getBean(SpringWebFluxTemplateEngine.class) + .getEnableSpringELCompiler()).isTrue(); + } + + @Test + public void enableSpringElCompilerIsDisabledByDefault() { + load(BaseConfiguration.class); + assertThat(this.context.getBean(SpringWebFluxTemplateEngine.class) + .getEnableSpringELCompiler()).isFalse(); + } + @Test public void templateLocationDoesNotExist() throws Exception { load(BaseConfiguration.class, @@ -194,18 +208,6 @@ public class ThymeleafReactiveAutoConfigurationTests { .isInstanceOf(GroupingStrategy.class); } - @Test - public void enableSpringElCompilerCanBeEnabled() { - load(BaseConfiguration.class, "spring.thymeleaf.enable-spring-el-compiler:true"); - assertThat(this.context.getBean(SpringWebFluxTemplateEngine.class).getEnableSpringELCompiler()).isTrue(); - } - - @Test - public void enableSpringElCompilerIsDisabledByDefault() { - load(BaseConfiguration.class); - assertThat(this.context.getBean(SpringWebFluxTemplateEngine.class).getEnableSpringELCompiler()).isFalse(); - } - private void load(Class config, String... envVariables) { this.context = new AnnotationConfigReactiveWebApplicationContext(); TestPropertyValues.of(envVariables).applyTo(this.context); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java index ece53317918..9362d91f817 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java @@ -112,6 +112,20 @@ public class ThymeleafServletAutoConfigurationTests { assertThat(views.getViewNames()).isEqualTo(new String[] { "foo", "bar" }); } + @Test + public void overrideEnableSpringElCompiler() { + load(BaseConfiguration.class, "spring.thymeleaf.enable-spring-el-compiler:true"); + assertThat(this.context.getBean(SpringTemplateEngine.class) + .getEnableSpringELCompiler()).isTrue(); + } + + @Test + public void enableSpringElCompilerIsDisabledByDefault() { + load(BaseConfiguration.class); + assertThat(this.context.getBean(SpringTemplateEngine.class) + .getEnableSpringELCompiler()).isFalse(); + } + @Test public void templateLocationDoesNotExist() throws Exception { load(BaseConfiguration.class, @@ -219,18 +233,6 @@ public class ThymeleafServletAutoConfigurationTests { assertThat(templateResolver.isCacheable()).isFalse(); } - @Test - public void enableSpringElCompilerCanBeEnabled() { - load(BaseConfiguration.class, "spring.thymeleaf.enable-spring-el-compiler:true"); - assertThat(this.context.getBean(SpringTemplateEngine.class).getEnableSpringELCompiler()).isTrue(); - } - - @Test - public void enableSpringElCompilerIsDisabledByDefault() { - load(BaseConfiguration.class); - assertThat(this.context.getBean(SpringTemplateEngine.class).getEnableSpringELCompiler()).isFalse(); - } - private void load(Class config, String... envVariables) { this.context = new AnnotationConfigWebApplicationContext(); TestPropertyValues.of(envVariables).applyTo(this.context);