有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Spring引导和Thymeleaf Neko HTML错误

我正在尝试运行一个使用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依赖项时,错误消失了。但是,它应该通过我当前的依赖项包括在内。有什么问题吗


共 (2) 个答案

  1. # 1 楼答案

    将此添加到pom.xml

    <!  https://mvnrepository.com/artifact/net.sourceforge.nekohtml/nekohtml  >
    <dependency>
        <groupId>net.sourceforge.nekohtml</groupId>
        <artifactId>nekohtml</artifactId>
        <version>1.9.22</version>
    </dependency>
    
  2. # 2 楼答案

    对于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'