升级的 Spring Boot Starter Parent - Thymeleaf 方言布局:装饰器坏了

Posted

技术标签:

【中文标题】升级的 Spring Boot Starter Parent - Thymeleaf 方言布局:装饰器坏了【英文标题】:Upgraded Spring Boot Starter Parent - Thymeleaf Dialect layout:decorator broke 【发布时间】:2019-01-23 08:30:53 【问题描述】:

我使用 spring-boot-starter-thymeleaf 包将 Spring Boot Starter Parent 从 1.3.3.RELEASE 升级到了当前的 2.0.4.RELEASE。升级后属性 layout:decorator 不再起作用。该属性未解析,而是包含未解析,例如

<!DOCTYPE html>
<html
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="layouts/admin.layout">
<head>
    <title>Admin</title>
</head>
<body>

pom.xml 包含在下面

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.j</groupId>
<artifactId>yggdrasil</artifactId>
<version>1</version>
<name>Yggdrasil</name>
<packaging>war</packaging>

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

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.7</java.version>
</properties>

<dependencies>
    <!-- Spring Boot -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <!-- Spring Boot Test -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <!-- Spring Security -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <!-- Thymeleaf -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>


    <!-- Web Jar libraries -->
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>jquery</artifactId>
        <version>2.1.4</version>
    </dependency>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>3.3.2</version>
    </dependency>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootswatch-sandstone</artifactId>
        <version>3.3.2</version>
    </dependency>

    <!-- WAR packaging -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <!-- Local dependencies -->


    <dependency>
        <groupId>com.j</groupId>
        <artifactId>f</artifactId>
        <version>1</version>
    </dependency>


    <dependency>
        <groupId>com.j</groupId>
        <artifactId>bl</artifactId>
        <version>1.0</version>
    </dependency>


    <dependency>
        <groupId>com.j</groupId>
        <artifactId>dc</artifactId>
        <version>1.0</version>
    </dependency>


    <dependency>
        <groupId>com.j</groupId>
        <artifactId>ss</artifactId>
        <version>1</version>
    </dependency>


    <dependency>
        <groupId>com.j</groupId>
        <artifactId>ff</artifactId>
        <version>1</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <!-- Tomcat plugin -->
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <url>SECRET</url>
                <server>Jengu Saturnus</server>
                <username>SECRET</username>
                <password>SECRET</password>
                <update>true</update>
                <systemProperties>
                    <spring.profiles.active>production</spring.profiles.active>
                </systemProperties>
            </configuration>
        </plugin>   
    </plugins>
    <finalName>$project.artifactId</finalName>
</build>

Spring Boot Starter Parent 2.0.4.RELEASE 中是否对方言有更多要求?

【问题讨论】:

【参考方案1】:

更新: 好像包 nz.net.ultraq.thymeleaf.LayoutDialect 没有通过 spring-boot-starter-thymeleaf 添加到类路径中?但是当我添加时:

<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
<version>2.3.0</version>
</dependency>

到它加载的 POM

【讨论】:

以上是关于升级的 Spring Boot Starter Parent - Thymeleaf 方言布局:装饰器坏了的主要内容,如果未能解决你的问题,请参考以下文章

从 Spring Boot Starter 1.3.5.RELEASE 升级到 1.5.2 RELEASE 时 Spring Security 中的访问被拒绝错误

Nacos 2.0的Spring Boot Starter来了!

rocketmq-spring-boot-starter 2.1.0 事务消息 txProducerGroup 移除解读

Spring Boot 2 Actuator Starter 中的 Nullpointer w。 Tomcat指标

从Spring Boot 1.5升级到2.0

Spring Boot Starter Data Redis使用Lettuce客户端报错:NOAUTH Authentication required