1

I am not able to access static content (angular app) or even a simple index.html file from spring-boot. I keep getting 404 error. Spring is not serving me with those static files. I have the problem since I have upgraded to Spring-Boot 2.2.4. I had to upgrade to counter Zip64 issue.

I have this line in my application.properties:

spring.resources.static-locations=classpath:/resources/,classpath:/static/

I also have my own staticResourceConfiguration class.

In my WebSecurity class, i have the following which is supposed to serve static content if the url path is matched to the below patterns. The problem is localhost:8080/index.html works and localhost:8080 return 404

        .antMatchers(HttpMethod.GET, "/**","/**/*.html", "/static/favicon.ico", "/**/*.js", "/**/*.js.map", "/**/*.css", "/**/*.png", "/**/*.jpg", "/**/*.jpeg", "/**/*.gif", "/**/*.ttf", "/**/*.json", "/**/*.woff", "/**/*.woff2", "/**/*.eot", "/**/*.svg","/**/*.json").permitAll()
Nesan Mano
  • 1,892
  • 2
  • 26
  • 43

1 Answers1

0

You can use this answer to improve your own
Spring Boot not serving static content

or this

@Configuration
public class StaticResourceConfiguration extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("file:/path/to/staticPage/");
    }
}
Augusto
  • 89
  • 6