I have an already existing client module with apache tiles and thymeleaf, what works well. I wanted to convert it to spring-boot and wanted to do it step by step, but I am r
This example demonstrate how to configure Thymeleaf with Apache tiles, but it is letting spring boot to autoconfigure Thymeleaf. This way you can still use all spring-boot predefined environment variables like spring.thymeleaf.* in your application.properties
@Configuration
@AutoConfigureAfter(ThymeleafAutoConfiguration.class)//tweak autoconfiguration for apache tiles after spring boot
@EnableConfigurationProperties(ThymeleafProperties.class)
public class ThymeleafTilesConfig {
@Autowired//this bean is autoconfigured with spring-boot-thymeleaf
private ThymeleafViewResolver thymeleafViewResolver;
@Autowired
private ThymeleafProperties properties;
@PostConstruct
public void setThymeleafTilesViewClass() {
//just set view class for thymeleaf-tiles
thymeleafViewResolver.setViewClass(ThymeleafTilesView.class);
}
@Bean
TilesDialect tilesDialect() {
// This bean will be auto picked-up by spring-boot and will be autoconfigured :)
return new TilesDialect();
}
@Bean//create tiles configurer for your needs
ThymeleafTilesConfigurer tilesConfigurer() {
final ThymeleafTilesConfigurer configurer = new ThymeleafTilesConfigurer();
configurer.setDefinitions("classpath:/templates/**/views.xml");
configurer.setCheckRefresh(!properties.isCache());
return configurer;
}
}
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java#L116