在jhipster 4 *中有一个ThymeleafConfiguration类,但是这个在5 *中消失了 所以我在课堂上的扩展不再起作用。我怎样才能使它工作。 这是我的ThymeleafConfiguration.java文件:
import static java.nio.charset.StandardCharsets.UTF_8;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
@Configuration
public class ThymeleafConfiguration {
@Bean
@Description("Thymeleaf template resolver serving HTML 5 emails")
public ClassLoaderTemplateResolver emailTemplateResolver() {
ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver();
emailTemplateResolver.setPrefix("templates/mail/");
// emailTemplateResolver.setSuffix(".html");
emailTemplateResolver.setTemplateMode("HTML5");
emailTemplateResolver.setCharacterEncoding(UTF_8.name());
emailTemplateResolver.setOrder(1);
return emailTemplateResolver;
}
@Bean
@Description("Thymeleaf template resolver serving HTML for pdf")
public ClassLoaderTemplateResolver pdfTemplateResolver() {
ClassLoaderTemplateResolver pdfTemplateResolver = new ClassLoaderTemplateResolver();
pdfTemplateResolver.setPrefix("pdf/");
pdfTemplateResolver.setSuffix(".html");
pdfTemplateResolver.setTemplateMode("HTML5");
pdfTemplateResolver.setCharacterEncoding(UTF_8.name());
pdfTemplateResolver.setOrder(2);
return pdfTemplateResolver;
}
}
config类仍然存在,但是除非我将它们放在template / mail /
中,否则找不到pdf了。谢谢!