异常信息: Error creating bean with name ‘viewResolver’ defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationWebMvcAutoConfigurationAdapter.class]:Initializationofbeanfailed;nestedexceptionisorg.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithname′org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfigurationThymeleaf3ConfigurationThymeleaf3ViewResolverConfiguration′:Unsatisfieddependencyexpressedthroughconstructorparameter1;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname′org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfigurationThymeleafDefaultConfiguration’: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfigurationThymeleafDefaultConfigurationEnhancerBySpringCGLIBb20dfd10]:Constructorthrewexception;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname′layoutDialect′definedinclasspathresource[org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationThymeleafWebLayoutConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [nz.net.ultraq.thymeleaf.LayoutDialect]: Factory method ‘layoutDialect’ threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/dom/Attribute

解决方式:项目的pom文件中propertis参数添加:<thymeleaf-layout-dialect.version>2.0.4</thymeleaf-layout-dialect.version>
thymeleaf在springboot中的完整配置:
1.添加坐标:
org.springframework.boot
spring-boot-starter-thymeleaf
org.assertj
assertj-core
2.pom中的propertis中添加两行
<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>
3.配置文件中添加相应配置。(其实也可以不配置,如果将html资源放置在templates的包下,则无需配置)
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.mode=HTML
spring.thymeleaf.cache=false
spring.thymeleaf.encoding=utf-8