【发布时间】:2014-07-05 12:52:53
【问题描述】:
我的 Spring Boot 应用程序在 Eclipse 和命令行中运行的 gradle 中运行良好。但是从 java -jar 启动时无法从子目录加载片段....
使用默认的 Spring Boot 和 Thymeleaf 设置和 gradle。
文件夹结构
src/main/resources/
---templates/
---homepages/
---homepage
---head
尝试了 Thymeleaf 的显式视图解析器。没有运气。
导致问题的片段。
<head th:include="/homepages/head"></head>
从 jar 启动时出错
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)
使用 Spring Boot 的默认设置。
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'
}
【问题讨论】:
标签: jar spring-boot thymeleaf build.gradle spring-java-config