From e5e511fd431737cc5336260a8c0543f65de39984 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 22 Oct 2013 17:17:07 +0100 Subject: [PATCH] Reinstate use of hasMappingForPattern Use of hasMappingForPattern was commented out during work on the Aether-based Grape implementation as it was temporarily removed in Spring 4's snapshots. It's since been reinstated in the snapshots, so its use should have been reinstated prior to merging Aether work into master. --- .../web/WebMvcAutoConfiguration.java | 15 ++++++++------- .../web/WebMvcAutoConfigurationTests.java | 2 -- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java index e77c25169b..d76f52896e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java @@ -175,13 +175,14 @@ public class WebMvcAutoConfiguration { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { - // if (!registry.hasMappingForPattern("/webjars/**")) { - registry.addResourceHandler("/webjars/**").addResourceLocations( - "classpath:/META-INF/resources/webjars/"); - // } - // if (!registry.hasMappingForPattern("/**")) { - registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); - // } + if (!registry.hasMappingForPattern("/webjars/**")) { + registry.addResourceHandler("/webjars/**").addResourceLocations( + "classpath:/META-INF/resources/webjars/"); + } + if (!registry.hasMappingForPattern("/**")) { + registry.addResourceHandler("/**").addResourceLocations( + RESOURCE_LOCATIONS); + } } @Override diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java index ab1e30e088..fa0fb09782 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java @@ -25,7 +25,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.After; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -57,7 +56,6 @@ import static org.junit.Assert.assertThat; * @author Phillip Webb * @author Dave Syer */ -@Ignore public class WebMvcAutoConfigurationTests { private static final MockEmbeddedServletContainerFactory containerFactory = new MockEmbeddedServletContainerFactory();