@@ -178,10 +178,8 @@ void handlerMappingsCreated() {
178
178
void resourceHandlerMapping () {
179
179
this .contextRunner .run ((context ) -> {
180
180
Map <String , List <Resource >> locations = getResourceMappingLocations (context );
181
- assertThat (locations .get ("/**" )).hasSize (5 );
182
- assertThat (locations .get ("/webjars/**" )).hasSize (1 );
183
- assertThat (locations .get ("/webjars/**" ).get (0 ))
184
- .isEqualTo (new ClassPathResource ("/META-INF/resources/webjars/" ));
181
+ assertThat (locations .get ("/**" )).hasSize (2 );
182
+ assertThat (locations .get ("/webjars/**" )).hasSize (0 );
185
183
assertThat (getResourceResolvers (context , "/webjars/**" )).hasSize (1 );
186
184
assertThat (getResourceTransformers (context , "/webjars/**" )).hasSize (0 );
187
185
assertThat (getResourceResolvers (context , "/**" )).hasSize (1 );
@@ -193,17 +191,17 @@ void resourceHandlerMapping() {
193
191
void customResourceHandlerMapping () {
194
192
this .contextRunner .withPropertyValues ("spring.mvc.static-path-pattern:/static/**" ).run ((context ) -> {
195
193
Map <String , List <Resource >> locations = getResourceMappingLocations (context );
196
- assertThat (locations .get ("/static/**" )).hasSize (5 );
194
+ assertThat (locations .get ("/static/**" )).hasSize (2 );
197
195
assertThat (getResourceResolvers (context , "/static/**" )).hasSize (1 );
198
196
});
199
197
}
200
198
201
199
@ Test
202
200
void resourceHandlerMappingOverrideWebjars () {
203
- this .contextRunner .withUserConfiguration (WebJars .class ).run ((context ) -> {
201
+ this .contextRunner .withUserConfiguration (WebJarsResources .class ).run ((context ) -> {
204
202
Map <String , List <Resource >> locations = getResourceMappingLocations (context );
205
203
assertThat (locations .get ("/webjars/**" )).hasSize (1 );
206
- assertThat (locations .get ("/webjars/**" ).get (0 )) .isEqualTo (new ClassPathResource ( "/foo/" ) );
204
+ assertThat (locations .get ("/webjars/**" ).get (0 ). getFilename ()) .isEqualTo ("test" );
207
205
});
208
206
}
209
207
@@ -212,7 +210,7 @@ void resourceHandlerMappingOverrideAll() {
212
210
this .contextRunner .withUserConfiguration (AllResources .class ).run ((context ) -> {
213
211
Map <String , List <Resource >> locations = getResourceMappingLocations (context );
214
212
assertThat (locations .get ("/**" )).hasSize (1 );
215
- assertThat (locations .get ("/**" ).get (0 )) .isEqualTo (new ClassPathResource ( "/foo/" ) );
213
+ assertThat (locations .get ("/**" ).get (0 ). getFilename ()) .isEqualTo ("test" );
216
214
});
217
215
}
218
216
@@ -1097,11 +1095,11 @@ protected void renderMergedOutputModel(Map<String, Object> model, HttpServletReq
1097
1095
}
1098
1096
1099
1097
@ Configuration (proxyBeanMethods = false )
1100
- static class WebJars implements WebMvcConfigurer {
1098
+ static class WebJarsResources implements WebMvcConfigurer {
1101
1099
1102
1100
@ Override
1103
1101
public void addResourceHandlers (ResourceHandlerRegistry registry ) {
1104
- registry .addResourceHandler ("/webjars/**" ).addResourceLocations ("classpath:/foo/" );
1102
+ registry .addResourceHandler ("/webjars/**" ).addResourceLocations (new ClassPathResource ( "/test" , getClass ()) );
1105
1103
}
1106
1104
1107
1105
}
@@ -1111,7 +1109,7 @@ static class AllResources implements WebMvcConfigurer {
1111
1109
1112
1110
@ Override
1113
1111
public void addResourceHandlers (ResourceHandlerRegistry registry ) {
1114
- registry .addResourceHandler ("/**" ).addResourceLocations ("classpath:/foo/" );
1112
+ registry .addResourceHandler ("/**" ).addResourceLocations (new ClassPathResource ( "/test" , getClass ()) );
1115
1113
}
1116
1114
1117
1115
}
@@ -1519,7 +1517,7 @@ ServletRegistrationBean<?> additionalDispatcherServlet(DispatcherServlet extraDi
1519
1517
}
1520
1518
1521
1519
@ Bean
1522
- private DispatcherServlet extraDispatcherServlet () throws ServletException {
1520
+ private DispatcherServlet extraDispatcherServlet () {
1523
1521
DispatcherServlet dispatcherServlet = new DispatcherServlet ();
1524
1522
AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext ();
1525
1523
applicationContext .register (ResourceHandlersWithChildAndParentContextChildConfiguration .class );
0 commit comments