我试图运行Spring Boot和Thymeleaf的例子。我得到这个错误:春季启动和Thymeleaf Neko HTML错误
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
当我添加ネHTML依赖错误消失。不过,它应该通过我目前的依赖包含在内。可能是什么问题?
你对。 Spring Boot确实可以管理nekohtml依赖项(所以你可以在没有版本的情况下添加依赖项),但是thymeleaf starter默认不会启用它。 –
对我来说令人惊讶:)似乎Neko HTML是Thymeleaf的必须品,但它并未包含在spring-boot-thymeleaf中。我以为我错过了什么。谢谢! – kamaci
例如,如果您使用HTML5模式,则根本不需要Neko库。作为一个可选的依赖关系,只有在项目需要时才会包含更好的结果。 –