Ganesh Krishnan
Ganesh Krishnan

Reputation: 7395

Spring boot with Thymeleaf 3 Beta

Spring boot does not seem to play well with Thymeleaf 3 beta.

java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration due to internal class not found. 

This can happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake) 

....

 Caused by: java.lang.NoClassDefFoundError: org/thymeleaf/resourceresolver/IResourceResolver

Any ideas on how I can make it work?

Essentially, I have prebuilt HTML templates which do not really conform to XHTML standards and I want to use this with Thymeleaf. Thymeleaf 2 does not support HTML and even the LEGACYHTML5 mode throws up errors due to angular markup

So, I am stuck with Spring Boot which only uses Thyme2 and no support for Thyme3 but my app would only work with Thyme3

Upvotes: 3

Views: 2631

Answers (2)

Andy Wilkinson
Andy Wilkinson

Reputation: 116171

Update: as of 1.4, Spring Boot support Thymeleaf 3 but version 2 remains the default. See the documentation for details on how to use Thymeleaf 3.

Spring Boot 1.3 and earlier don't support Thymeleaf 3. You'll need to disable Boot's auto-configuration for Thymeleaf and configure it manually. You can disable an auto-configuration by using the exclude attribute on @SpringBootApplication:

@SpringBootApplication(exclude=org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration.class)

Upvotes: 3

Tim Christensen
Tim Christensen

Reputation: 91

This is the correct answer. Here is the class to exclude to make it easier for the next person with this issue:

@SpringBootApplication(exclude={org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration.class})

Upvotes: 8

Related Questions