栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Spring Boot和Thymeleaf:找不到HTML模板

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/635720.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号