Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Boot-Eleaf片段子目录视图错误,带有jar_Jar_Spring Boot_Thymeleaf_Build.gradle_Spring Java Config - Fatal编程技术网

Spring Boot-Eleaf片段子目录视图错误,带有jar

Spring Boot-Eleaf片段子目录视图错误,带有jar,jar,spring-boot,thymeleaf,build.gradle,spring-java-config,Jar,Spring Boot,Thymeleaf,Build.gradle,Spring Java Config,我的Spring Boot应用程序在Eclipse中运行良好,并在命令行中从gradle运行。但是,当从java-jar启动时,无法从子目录加载片段 使用默认的Spring引导和Thymeleaf设置以及gradle 文件夹结构 src/main/resources/ ---templates/ ---homepages/ ---homepage ---head 已尝试为Thymeleaf使用显式视图解析器。不走运 导致问题的碎片 <

我的Spring Boot应用程序在Eclipse中运行良好,并在命令行中从gradle运行。但是,当从java-jar启动时,无法从子目录加载片段

使用默认的Spring引导和Thymeleaf设置以及gradle

文件夹结构

src/main/resources/
---templates/
      ---homepages/
           ---homepage
           ---head
已尝试为Thymeleaf使用显式视图解析器。不走运

导致问题的碎片

<head th:include="/homepages/head"></head>
使用Spring引导的默认设置

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'
}

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

成功了,Dave。谢谢忽略了它,因为在SpringBoot应用程序启动和GradleBootRun中一切都很好。我仍然不明白这一点,但一定要坚持正确的语法。
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'
}