2014-05-16 26 views
4

我的春季启动应用程序在Eclipse中运行良好,并从命令行运行gradle。然而,当从java -jar启动时,无法从子目录加载片段....弹簧启动Thymeleaf碎片子目录查看错误与罐子

使用默认的Spring Boot和Thymeleaf设置和gradle。

文件夹结构

src/main/resources/ 
---templates/ 
     ---homepages/ 
      ---homepage 
      ---head 

尝试明确视图Thymeleaf解析器。没有运气。

片段引发问题。从罐子

Whitelabel Error Page 

This application has no explicit mapping for /error, so you are seeing this as a fallback. 
Fri May 16 18:54:44 EDT 2014 
There was an unexpected error (type=Internal Server Error, status=500). 
Error resolving template "/homepages/head", template might not exist or might not be accessible by any of the configured Template Resolvers (homepages/homepage:5) 

推出了采用默认设置春季开机的时候

<head th:include="/homepages/head"></head> 

错误。

buildscript { 
    repositories { 
     maven { url "http://repo.spring.io/libs-snapshot" } 
     mavenLocal() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.0.2.RELEASE") 
    } 
} 

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'idea' 
apply plugin: 'spring-boot' 

jar { 
    baseName = 'base-app' 
    version = '0.1.0' 
} 

repositories { 
    mavenCentral() 
    maven { url "http://repo.spring.io/libs-snapshot" } 
    maven { url "https://repository.jboss.org/nexus/content/repositories/releases" } 
} 


dependencies { 
    compile("org.springframework.boot:spring-boot-starter-web") { 
    } 
    compile("org.springframework.boot:spring-boot-starter-security") 
    compile("org.thymeleaf:thymeleaf-spring4") 
    testCompile("junit:junit") 

    compile("org.springframework.boot:spring-boot-starter-data-jpa") 
    compile("org.springframework.boot:spring-boot-starter-jdbc") 
    compile("org.postgresql:postgresql:9.2-1004-jdbc4") 
    compile("org.hibernate:hibernate-validator") 
    compile('org.hibernate:hibernate-entitymanager:4.0.1.Final') 
    compile("org.springframework:spring-tx") 
    compile("org.springframework.boot:spring-boot-starter-actuator") 

} 

task wrapper(type: Wrapper) { 
    gradleVersion = '1.11' 
} 

回答

2

模板路径通常不以“/”开头。尝试从包含路径中删除它。

+0

工作,戴夫。谢谢!忽略它是因为在Spring Boot App启动和gradle bootrun中一切正常。仍然不明白,但会确保坚持正确的语法。 – user2880771