Spring Boot和Thymeleaf Neko HTML错误

kam*_*aci 3 java spring spring-mvc thymeleaf spring-boot

我试图用Spring Boot和Thymeleaf运行一个例子.我收到了这个错误:

出现意外错误(type = Internal Server Error,status = 500).无法从旧版HTML执行到XML的转换:nekoHTML库不在类路径中.在"LEGACYHTML5"模式下处理模板需要nekoHTML 1.9.15或更高版本

这些是我的依赖:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jersey</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-springsecurity4</artifactId>
        <version>2.1.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

这是我的应用程序属性:

spring.thymeleaf.cache=false
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
Run Code Online (Sandbox Code Playgroud)

当我添加Neko HTML依赖性错误消失.但是它应该通过我当前的依赖项包含在内.可能是什么问题?

kuh*_*yan 5

对于Maven,简单地添加这个依赖:

mvn依赖:tree -Dincludes = net.sourceforge.nekohtml:nekohtml

结果没什么

似乎spring-boot-thymeleaf不包含nekohtml库.


对于gradle,您可以在https://mvnrepository.com/artifact/net.sourceforge.nekohtml/nekohtml中找到所需的版本,并找到gradle include脚本,如下所示:

compile group: 'net.sourceforge.nekohtml', name: 'nekohtml', version: '1.9.22'
Run Code Online (Sandbox Code Playgroud)