You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ThymeleafViewResolver appears to treat views as self-contained beans, and at line 661 it calls beanFactory.autowireBeanProperties on them. This causes an exception when attempting to use the view resolver with a standalone MockMvc context, which is a stub context and doesn't support autowiring:
Caused by: java.lang.UnsupportedOperationException
at org.springframework.test.web.servlet.setup.StubWebApplicationContext$StubBeanFactory.autowireBeanProperties(StubWebApplicationContext.java:365)
at org.thymeleaf.spring4.view.ThymeleafViewResolver.loadView(ThymeleafViewResolver.java:661)
at org.thymeleaf.spring4.view.ThymeleafViewResolver.createView(ThymeleafViewResolver.java:626)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:156)
at org.springframework.web.servlet.DispatcherServlet.resolveViewName(DispatcherServlet.java:1283)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1224)
at org.springframework.test.web.servlet.TestDispatcherServlet.render(TestDispatcherServlet.java:105)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
... 22 more
This behaviour seems to have been fixed in the Spring MVC Test framework itself, and now StubWebApplicationContext$StubBeanFactory.autowireBeanProperties(...) does not raise an UnsupportedOperationException anymore.
The
ThymeleafViewResolver
appears to treat views as self-contained beans, and at line 661 it callsbeanFactory.autowireBeanProperties
on them. This causes an exception when attempting to use the view resolver with a standalone MockMvc context, which is a stub context and doesn't support autowiring:This is triggered from this MockMvc setup:
Is there any simple way to render Thymeleaf views with a MockMvc standalone setup?
The text was updated successfully, but these errors were encountered: