Skip to content

Spring Boot static resource locations

In Spring Boot, the default locations for serving static resources (such as JavaScript, CSS, or images) are derived from the ResourceProperties class configuration.^[spring-thymeleaf-01.md]

Default Resource Locations

By default, Spring Boot searches for static resources in four specific classpath locations^[spring-thymeleaf-01.md]:

  • classpath:/META-INF/resources/
  • classpath:/resources/
  • classpath:/static/
  • classpath:/public/

These locations are defined in the source code as a string array constant CLASSPATH_RESOURCE_LOCATIONS and assigned to the staticLocations property^[spring-thymeleaf-01.md].

Configuration and Handling

The loading and handling of these resources are managed by the WebMvcAutoConfiguration class^[spring-thymeleaf-01.md]. This auto-configuration sets up resource handlers to map requests to the physical locations defined above.

Sources

  • spring-thymeleaf-01.md