Thymeleaf热更新不需要ctrl+f9即可修改页面

Thymeleaf热更新不需要ctrl+f9即可修改页面

Properties文件中配置

spring.thymeleaf.cache=false
spring.thymeleaf.templates_root=src/main/resources/templates/

再加一个Configuration

@Configuration
@Profile("dev")
public class ThymeleafConfig {
    @Autowired
    private ThymeleafProperties properties;

    @Value("${spring.thymeleaf.templates_root:}")
    private String templatesRoot;

    @Bean
    public ITemplateResolver defaultTemplateResolver() {
        FileTemplateResolver resolver = new FileTemplateResolver();
        resolver.setSuffix(properties.getSuffix());
        resolver.setPrefix(templatesRoot);
        resolver.setTemplateMode(properties.getMode());
        resolver.setCacheable(properties.isCache());
        return resolver;
    }
}

有问题的话需要调整templates_root的值!

你可能感兴趣的:(JAVAEE)