Reputation: 1033
I'm following the below tutorial which is based on sending an email using Thymeleaf template.
link to the tutorial: http://www.thymeleaf.org/doc/articles/springmail.html
In this example TemplateMode is being used in several instances
private ITemplateResolver textTemplateResolver() {
final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setOrder(Integer.valueOf(1));
templateResolver.setResolvablePatterns(Collections.singleton("text/*"));
templateResolver.setPrefix("/mail/");
templateResolver.setSuffix(".txt");
templateResolver.setTemplateMode(TemplateMode.TEXT);
templateResolver.setCharacterEncoding(EMAIL_TEMPLATE_ENCODING);
templateResolver.setCacheable(false);
return templateResolver;
}
private ITemplateResolver htmlTemplateResolver() {
final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setOrder(Integer.valueOf(2));
templateResolver.setResolvablePatterns(Collections.singleton("html/*"));
templateResolver.setPrefix("/mail/");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode(TemplateMode.HTML);
templateResolver.setCharacterEncoding(EMAIL_TEMPLATE_ENCODING);
templateResolver.setCacheable(false);
return templateResolver;
}
While I was searching for it I found it is in org.thymeleaf.templatemode.TemplateMode but I cant import it to my project
So TemplateMode gives me errors. How to fix the error?
Upvotes: 0
Views: 3496
Reputation: 47935
The class org.thymeleaf.templatemode.TemplateMode
was added in Thymeleaf 3.0.0.
As long as you depend on a version of Thymeleaf >= 3.0.0 then TemplateMode
will be available to you so the fact that TemplateMode
is not available on your project's classapth strongly implies that you are using a version of Thymeleaf < 3.0.0.
The bottom line is that the example you linked to uses Thymeleaf >= 3.0.0
whereas you are using Thymeleaf < 3.0.0
.
FWIW, your question also tags spring
so perhaps you are acquiring your Thymeleaf dependency transitively (via spring-boot-starter-thymeleaf
perhaps?). You could run mvn dependency:tree
and review the output for: org.thymeleaf:thymeleaf
to understand (a) what version of Thymeleaf you are using and (b) where this version comes from.
Upvotes: 2