Browse Source

Change exception message for missing Thymeleaf templates

Fixes gh-424
pull/450/head
Dave Syer 12 years ago
parent
commit
ffe91ca6bf
  1. 7
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
  2. 4
      spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java

7
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java

@ -84,8 +84,11 @@ public class ThymeleafAutoConfiguration { @@ -84,8 +84,11 @@ public class ThymeleafAutoConfiguration {
if (checkTemplateLocation) {
Resource resource = this.resourceLoader.getResource(this.environment
.getProperty("prefix", DEFAULT_PREFIX));
Assert.state(resource.exists(), "Cannot find template location: "
+ resource + " (are you really using Thymeleaf?)");
Assert.state(
resource.exists(),
"Cannot find template location: "
+ resource
+ " (please add some templates or check your Thymeleaf configuration)");
}
}

4
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java

@ -16,11 +16,11 @@ @@ -16,11 +16,11 @@
package org.springframework.boot.autoconfigure.thymeleaf;
import java.io.File;
import java.util.Collections;
import java.util.Locale;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
@ -95,8 +95,8 @@ public class ThymeleafAutoConfigurationTests { @@ -95,8 +95,8 @@ public class ThymeleafAutoConfigurationTests {
}
@Test
@Ignore("Fix this for gh-424")
public void templateLocationEmpty() throws Exception {
new File("target/test-classes/templates/empty-directory").mkdir();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.thymeleaf.prefix:classpath:/templates/empty-directory/");
this.context.register(ThymeleafAutoConfiguration.class,

Loading…
Cancel
Save