Skip to content

Document how to use WebJars without webjars-locator-core dependency #29322

Closed
@sdeleuze

Description

@sdeleuze

Given current efficiency impact of webjars-locator-core (see this related comment), an its incompatibility with native images, it makes sense to recommend to use versioned URLs with this kind of configuration instead of WebJarsResourceResolver without including webjars-locator-core dependency in Spring reference documentation.

@Bean
public WebMvcConfigurer configurer() {
	return new WebMvcConfigurer() {
		@Override
		public void addResourceHandlers(ResourceHandlerRegistry registry) {
			registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:META-INF/resources/webjars/");
		}
	};
}

We can refine later recommending the regular webjars-locator-core + WebJarsResourceResolver approach with version-less URLs if/when webjars-locator-core implement resource resolution without scanning, which seems to be possible as experimented in #27619.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions