springboot+thymeleaf模板的一個問題,搞了一天才搞定。

thymeleaf中使用layout功能,根據官方的文檔,看上去很是的簡單,可是就是各類搞不定。百度谷歌都沒能查到有效的方案,有些方案是須要再寫代碼配置。java

直到後來我在pom文件中更新的Thymeleaf的版本,才搞定。mysql

原來我開發的時候,是從springboot官網http://projects.spring.io/spring-boot/#quick-start上下載了一個工程文件,這個工程文件裏面的pom引用的版本居然是舊的。web

我也不知道爲啥是這樣,後來複寫了一些版本號才搞定。真的坑死我了。下面是POM文件,主要看粗體字部分。spring

 

<?xml version="1.0" encoding="UTF-8"?>sql

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"apache

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">springboot

<modelVersion>4.0.0</modelVersion>maven

<groupId>com.qmath</groupId>ide

<artifactId>xlab</artifactId>spring-boot

<version>0.0.1-SNAPSHOT</version>

<packaging>jar</packaging>

<name>xlab</name>

<description>Demo project for Spring Boot</description>

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>1.5.6.RELEASE</version>

<relativePath /> <!-- lookup parent from repository -->

</parent>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<java.version>1.8</java.version>

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

<thymeleaf-layout-dialect.version>2.0.4</thymeleaf-layout-dialect.version>

</properties>

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-data-jpa</artifactId>

</dependency>

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

<scope>runtime</scope>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-test</artifactId>

<scope>test</scope>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-thymeleaf</artifactId>

</dependency>

<dependency>

<groupId>nz.net.ultraq.thymeleaf</groupId>

<artifactId>thymeleaf-layout-dialect</artifactId>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

</plugin>

</plugins>

</build>

</project>

相關文章
相關標籤/搜索