Spring Boot和Thymeleaf:找不到HTML模板

Spring Boot和Thymeleaf:找不到HTML模板,第1张

Spring Boot和Thymeleaf:找不到HTML模板

Spring
Boot会自动为您完成一些内部工作,但是要进行自动工作,您需要对其进行适当的配置。这是您问题2的答案,如果配置正确,spring会自动提供视图解析器。好的,现在转到问题1。

如果将pom.xml与petclinic的pom.xml进行比较,您将看到一些关键差异。

首先,根据spring官方文档http://docs.spring.io/spring-
boot/docs/current/reference/html/using-boot-build-systems.html#using-boot-
maven,Maven

用户可以继承从spring-boot-starter-parent项目中获取合理的默认值。父项目提供了一些功能。要将项目配置为从spring-
boot-starter-parent继承,只需在pom.xml中设置父项即可。

<parent>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-parent</artifactId>    <version>1.5.1.RELEASE</version></parent>

使用该设置,您还可以通过覆盖自己项目中的属性来覆盖各个依赖项。例如,在petclinic pom.xml中,他们指定了您的百里香叶版本

<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>

现在,要正确设置Thymeleaf和Thymeleaf布局方言版本并使其兼容,您需要从spring-boot-starter-
thymeleaf中排除thymeleaf-layout-dialect,即将thymeleaf版本设置为3.0.2.RELEASE版本。

    <dependency>      <groupId>org.springframework.boot</groupId>      <artifactId>spring-boot-starter-thymeleaf</artifactId>      <exclusions>        <exclusion> <groupId>nz.net.ultraq.thymeleaf</groupId> <artifactId>thymeleaf-layout-dialect</artifactId>        </exclusion>      </exclusions>    </dependency>


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5641590.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存