Last active
January 3, 2024 07:27
-
-
Save djkeh/6e1d557ce8c466135b1541d342b1c25c to your computer and use it in GitHub Desktop.
Thymeleaf Decoupled Logic configuration for Spring Boot + Thymeleaf 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.boot.context.properties.ConfigurationProperties; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver; | |
@Configuration | |
public class ThymeleafConfig { | |
@Bean | |
public SpringResourceTemplateResolver thymeleafTemplateResolver( | |
SpringResourceTemplateResolver defaultTemplateResolver, | |
Thymeleaf3Properties thymeleaf3Properties | |
) { | |
defaultTemplateResolver.setUseDecoupledLogic(thymeleaf3Properties.decoupledLogic()); | |
return defaultTemplateResolver; | |
} | |
@ConfigurationProperties("spring.thymeleaf3") | |
public record Thymeleaf3Properties(boolean decoupledLogic) {} | |
} |
👍
👍
I've updated the code simpler using java record.
The new code was tested and utilized on the project below:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍