Error resolving template with Thymeleaf from test execution environment using Spring 3.2 Test Framework

StackOverflow https://stackoverflow.com/questions/17359705

Pregunta

Just trying to use the new features from Spring 3.2 testing framework in order to have real integration tests on the web layer. I'm running across a problem when triggering the tests with the "SpringJUnit4ClassRunner" in Spring 3.2 because the template engine complains about not being able to resolve the template name:

2013-06-28 09:29:18,372 ERROR TemplateEngine - [THYMELEAF][main] Exception processing template "mobile/index": Error resolving template "mobile/index", template might not exist or might not be accessible by any of the configured Template Resolvers

Of course, the engine is searching for the resource around /WEB-INF/views/mobile/index.html, what is correct in a normal execution mode, but does not exist along the test execution environment in the class path with: *classpath (src/test/resources) in a Maven based project * /WEB-INF/views/mobile/index.html

Is there anyway to make the engine get the resources from the "real path" in order not to maintain a copy of each html view in the test classpath?

Thanks in advance,

¿Fue útil?

Solución

One solution is having all the views under "/src/main/resources/views" and using the

org.thymeleaf.templateresolver.ClassLoaderTemplateResolver

This way you don't have any dependency (rather than using the "FileTemplateResolver") on the system and also you do not need having any duplicated spring configuration files for the test execution context.

Still it's a bit weird for me having the views in there but... Why not?

Any comment/suggestion over having the views under resource folders?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top