当我从https://spring.io/guides/gs/serving-web-content/中的gradle文件切换到多项目gradle文件设置时,我得到了一个奇怪的行为(至少对我来说是:D)。
根目录中的build.gradle
//Applied to all projects.
allprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
group = 'de.test.platform'
version = '0.1'
}
subprojects {
//Currently all subprojects are also java projects. If this changes we
//need to move it into the corresponding projects
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}
idea {
module {
downloadSources = true
downloadJavadoc = false
}
}
}
idea {
project {
jdkName = '1.8'
languageLevel = '1.8'
}
}在子目录build.gradle中的前端(因此子项目称为:前端)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
apply plugin: 'war'
apply plugin: 'spring-boot'
jar {
baseName = 'crowdio-frontend'
version = '0.1.0'
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("junit:junit")
}当我运行gradle bootRun并导航到本教程中的http://localhost:8080/greeting时,我得到了一个无限循环错误。如果我将模板从greeting.html更改为hello.html,并在控制器greeting()操作中返回hello而不是greeting,我会得到一个404错误。
模板存储在project_root/frontend/src/main/resources/templates/greeting.html中
发布于 2015-07-25 23:53:06
看起来,不管出于什么原因,spring boot都可以根据gradle构建文件的确切结构来选择胸腺叶,就像在本教程中一样。但是,如果切换到多项目设置,则需要添加
compile("org.thymeleaf:thymeleaf-spring4")作为依赖项。
https://stackoverflow.com/questions/31615159
复制相似问题