Not loading static Resources in Spring boot, Thymeleaf and AngularJs app

后端 未结 1 1070
无人及你
无人及你 2021-01-14 13:10

I have a Spring Boot project which has to start an angular spa. The structure of the resource folder is the following:

相关标签:
1条回答
  • 2021-01-14 13:34

    Update the resource location to point to your classpath.

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/js/**")
                .addResourceLocations("classpath:/templates/src/js/");
    }
    

    Spring Boot also adds static content automatically from the following classpath locations:

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

    Source: Serving Static Web Content with Spring Boot

    0 讨论(0)
提交回复
热议问题