带有 Gradle 的 SpringBoot 缺少 Thymeleaf 的依赖

Jas*_*son 5 spring thymeleaf

我正在尝试使用 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'
}
Run Code Online (Sandbox Code Playgroud)

很确定我的所有设置都正确,所以我继续运行以下构建步骤......

在此处输入图片说明

在此之后,我期待在我的“项目和外部依赖项”中看到spring-boot-starter-thymeleaf.jar但它不在那里。我对 Gradle 非常陌生,并假设构建会引入这个必需的依赖项,然后在启动我的应用程序时它会被“启用”。任何线索我可能在这里做错了什么?

在此处输入图片说明

这是我的 .html 页面,我希望在浏览器中看到“测试”。

在此处输入图片说明

小智 4

您需要更新依赖项。在 Package Explorer 上: -> 右键单击​​您的项目 -> Gradle -> 启用依赖项管理 -> 再次右键单击它 -> 刷新依赖项