【发布时间】:2016-08-19 15:19:25
【问题描述】:
我正在尝试使用 Thymeleaf 作为我的模板引擎来设置一个非常简单的 Springboot 应用程序。我 %100 确定我的 @Controller 工作正常,但是当我尝试访问默认 url ("/") 时,我得到了可怕的 "Whitelabel" 错误页面。
下面是我的 gradle.build 文件...
buildscript {
ext { springBootVersion = '1.4.0.RELEASE' }
repositories { mavenCentral() }
dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") }
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
jar {
baseName = 'masterSpringMvc'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories { mavenCentral() }
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
很确定我已正确设置所有内容,因此我继续运行以下构建步骤...
在此之后,我希望在“项目和外部依赖项”中看到 spring-boot-starter-thymeleaf.jar,但它不存在。我对 Gradle 很陌生,并假设构建会引入这个所需的依赖项,然后在启动我的应用程序时它会被“启用”。任何线索我在这里可能做错了什么?
这是我的 .html 页面,我希望在浏览器中看到“测试”。
【问题讨论】:
-
仅供参考,我花了几分钟时间创建了一个基于 Maven 的项目,该项目完全相同并且工作正常(我对 Maven 非常满意,但想知道我做错了什么Gradle,其 99.9% 与帖子中提到的不引入依赖项有关)