Skip to content

Commit 0f17142

Browse files
committed
Make GroovyWebConfiguration conditional on spring-webmvc's availability
GroovyWebConfiguration creates a GroovyTemplateViewResolver which is a UrlBasedViewResolver sub-class. UrlBasedViewResolver is provided by spring-webmvc. Previously, if a user configured a web application but did not have spring-webmvc on the classpath, the application would fail to start with a NoClassDefFoundError for UrlBasedViewResolver. This commit makes GroovyWebConfiguration conditional on UrlBasedViewResolver being on the classpath so that it backs of in the absence of spring-webmvc. Fixes gh-1793
1 parent e2dd659 commit 0f17142

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@
4747
import org.springframework.core.io.DefaultResourceLoader;
4848
import org.springframework.core.io.Resource;
4949
import org.springframework.core.io.ResourceLoader;
50+
import org.springframework.web.servlet.view.UrlBasedViewResolver;
5051

5152
/**
5253
* Autoconfiguration support for Groovy templates in MVC. By default creates a
5354
* {@link MarkupTemplateEngine} configured from {@link GroovyTemplateProperties}, but you
5455
* can override that by providing a {@link TemplateEngine} of a different type.
5556
*
5657
* @author Dave Syer
58+
* @author Andy Wilkinson
5759
* @since 1.1.0
5860
*/
5961
@Configuration
@@ -144,7 +146,8 @@ public TemplateEngine groovyTemplateEngine() throws Exception {
144146
}
145147

146148
@Configuration
147-
@ConditionalOnClass({ Servlet.class, LocaleContextHolder.class })
149+
@ConditionalOnClass({ Servlet.class, LocaleContextHolder.class,
150+
UrlBasedViewResolver.class })
148151
@ConditionalOnWebApplication
149152
public static class GroovyWebConfiguration {
150153

0 commit comments

Comments
 (0)