Skip to content

Instantly share code, notes, and snippets.

@djkeh
Last active January 3, 2024 07:27
Show Gist options
  • Save djkeh/6e1d557ce8c466135b1541d342b1c25c to your computer and use it in GitHub Desktop.
Save djkeh/6e1d557ce8c466135b1541d342b1c25c to your computer and use it in GitHub Desktop.
Thymeleaf Decoupled Logic configuration for Spring Boot + Thymeleaf 3
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) {}
}
@matrixpower1004
Copy link

👍

@congsole
Copy link

congsole commented Jan 3, 2024

👍

@djkeh
Copy link
Author

djkeh commented Jan 3, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment