我正在尝试使用 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/