Baljeet Singh Baljeet Singh - 4 months ago 63
Java Question

empty constructor is not defined in Thymeleaf source jar

I am learning Thymeleaf from below url

http://www.concretepage.com/spring-4/spring-4-security-thymeleaf-integration-custom-login-page-and-logout-example-with-csrf-token-using-javaconfig

Instead on using Gradle, I have downloaded all required jars from Thymeleaf official page.
Why does eclipse is throwing compile error at ThymeleafConfig class at line

ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();


The error is "constructor ServletContextTemplateResolver() is undefined".
On deep research i found that this constructor requires servlet context as input.
Every other example on web is using similar.
My question is if empty constructor is not defined in Thymeleaf source jar, how is everyone using it or what can be done in my case to resolve it ?

Answer

Concerning

On deep research i found that this constructor requires servlet context as input.

You're looking at the most recent version of the class. The constructor does indeed require a ServletContext argument.

However, that wasn't always the case, in previous versions, the constructor declared no parameters.

The tutorials you're looking at are probably using those older versions. Use the one that is appropriate for your environment.

Comments