content: package com.domaindns.config;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.thymeleaf.spring6.SpringTemplateEngine;
  import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
  
  @Configuration
  public class ThymeleafConfig {
  
      @Bean
      public ClassLoaderTemplateResolver emailTemplateResolver() {
          ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
          templateResolver.setPrefix("templates/email/");
          templateResolver.setSuffix(".html");
          templateResolver.setTemplateMode("HTML");
          templateResolver.setCharacterEncoding("UTF-8");
          templateResolver.setCacheable(false); // 开发环境关闭缓存
          return templateResolver;
      }
  
      @Bean
      public SpringTemplateEngine templateEngine() {
          SpringTemplateEngine templateEngine = new SpringTemplateEngine();
          templateEngine.setTemplateResolver(emailTemplateResolver());
          return templateEngine;
      }
  }
  