首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Boot教程不适用于多项目gradle设置

Spring Boot教程不适用于多项目gradle设置
EN

Stack Overflow用户
提问于 2015-07-25 00:10:32
回答 1查看 284关注 0票数 1

当我从https://spring.io/guides/gs/serving-web-content/中的gradle文件切换到多项目gradle文件设置时,我得到了一个奇怪的行为(至少对我来说是:D)。

根目录中的build.gradle

代码语言:javascript
复制
//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中的前端(因此子项目称为:前端)

代码语言:javascript
复制
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中

EN

回答 1

Stack Overflow用户

发布于 2015-07-25 23:53:06

看起来,不管出于什么原因,spring boot都可以根据gradle构建文件的确切结构来选择胸腺叶,就像在本教程中一样。但是,如果切换到多项目设置,则需要添加

代码语言:javascript
复制
compile("org.thymeleaf:thymeleaf-spring4")

作为依赖项。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31615159

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档