Thymeleaf 内容助手无法与 Spring Boot 配合使用

ArL*_*ArL 5 java spring thymeleaf spring-boot

thymeleaf 内容辅助不起作用,当我在 HTML 文件中输入 th: 前缀时,仅显示 th:block 提案。

<th:block
Run Code Online (Sandbox Code Playgroud)

我尝试将 Thymeleaf 处理器建议移至 HTML 文件的 STS/elipse 设置中的顶部,但不起作用。

该项目是Spring Boot + Thymeleaf,Gradle片段:

plugins {
    id 'org.springframework.boot' version '2.1.4.RELEASE'
    id 'java'
}

apply plugin: 'io.spring.dependency-management'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation "org.springframework.boot:spring-boot-starter-thymeleaf"
    implementation "org.springframework.boot:spring-boot-devtools"
}
Run Code Online (Sandbox Code Playgroud)

我添加了 html 命名空间:

<html xmlns:th="http://www.thymeleaf.org">
Run Code Online (Sandbox Code Playgroud)

将 th 名称空间更改为另一个名称空间不起作用;

好吧,唯一的工作时间是 th 只是替换了 HTML th 位置......

<table>
        <tbody>
            <tr th:
Run Code Online (Sandbox Code Playgroud)

小智 3

我遇到了同样的问题,我执行了以下步骤。

  1. 打开工作空间.metadata下的.log文件

  2. 之后打开 Thymeleaf 模板 (html):按 Ctrl+sapce

  3. 检查.log文件中的异常在我的例子中,这是groovy运行时异常,所以我卸载并安装了groovy插件重新启动eclipse,thymeleaf内容助手开始工作。

    [ groovy.lang.GroovyRuntimeException:找不到匹配的构造函数:org.thymeleaf.extras.eclipse.contentassist.autocomplete.proposals.AttributeProcessorCompletionProposal(org.thymeleaf.extras.eclipse.dialect.xml.ElementProcessor,整数,整数,布尔) ]

截屏