Prevent spring from initializing webjar handler mapping at startup

I recently observed a case where an application does not use webjars in a service, yet the application is exposing the path. Generally this does not have any impact, but as spring and spring-boot are often deployed to run web services where there is no expectation of a user interface, this seems a bit heavy.

Seen in startup console as:

2024-08-14 09:01:001.033 DEBUG [] _.s.web.servlet.HandlerMapping.Mappings : 'resourceHandlerMapping' {/webjars/=ResourceHttpRequestHandler [classpath [META-INF/resources/webjars/]], /=ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]}


For application.properties, use:

spring.web.resources.add-mappings=false

For application.yml, format as:

spring:
 web:
   resources:
     add-mappings: false

REFERENCES: