java - Spring Boot 和 Thymeleaf Neko HTML 错误

标签 java spring spring-mvc spring-boot thymeleaf

我正在尝试使用 Spring Boot 和 Thymeleaf 运行示例。我收到那个错误:

There was an unexpected error (type=Internal Server Error, status=500). Cannot perform conversion to XML from legacy HTML: The nekoHTML library is not in classpath. nekoHTML 1.9.15 or newer is required for processing templates in "LEGACYHTML5" mode

这些是我的依赖项:

    <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>

这是我的应用程序属性:

spring.thymeleaf.cache=false
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html

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

最佳答案

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

mvn dependency: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'

关于java - Spring Boot 和 Thymeleaf Neko HTML 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39355821/

相关文章:

spring - 如何使用 spring 配置 Hazelcast 以进行 session 缓存,同时将其限制为一组节点?

java - Spring 中的 PropertyEditor、Formatter 和 Converter 有什么区别?

java - ibatis 对于 "Insert"命令返回 NULL,而不是受影响的行数

java - TreeSet 比较器或 comparble.compareTo() 优先级

Java Swing无法显示

Spring 安全 3.2 + Tomcat 6.0.24

javascript - 如何在表单提交后添加成功通知

java - 安卓 : Issue in creating pie chart in a fragment

Spring Boot (Spring Data JPA) - 配置PostgreSQL只读副本

java - 在企业系统中使用异步方法