手动引入thymeleaf-layout-dialect

本文介绍在Spring Boot 2.0及更高版本中,如何手动引入Thymeleaf Layout Dialect来增强Thymeleaf模板布局功能。由于2.0版本后Spring Boot不再默认包含此依赖,文章提供了正确的Gradle配置示例。

最近在研究用 java 写网站,在使用 spring-boot-starter-thymeleaf 的 thymeleaf-layout-dialect 时老是无效,查阅了网站才知道,2.0之前的 spring-boot-starter-thymeleaf 自带 thymeleaf-layout-dialect 。2.0之后就没有自带了。那么怎么手动引入呢?

应该是

compile 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'

而不是像 spring-boot-starter-thymeleaf 那样引入

compile 'org.springframework.boot:spring-boot-starter-thymeleaf'

最后附上完整的 build.gradle

plugins {
    id 'org.springframework.boot' version '2.1.4.RELEASE'
    id 'java'
}

apply plugin: 'io.spring.dependency-management'

group = 'masterSpringMvc'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
    compile 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
    compile 'org.webjars:materializecss:1.0.0'
    compile 'org.webjars:jquery:2.1.4'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.projectreactor:reactor-test'
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值