手动引入thymeleaf-layout-dialect

最近在研究用 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'
}

 

你可能感兴趣的:(web,java,springMVC)