Spring Boot not serving static content

I can’t get my Spring-boot project to serve static content.

I’ve placed a folder named static under src/main/resources. Inside it I have a folder named images. When I package the app and run it, it can’t find the images I have put on that folder.

I’ve tried to put the static files in public, resources and META-INF/resources but nothing works.

If I jar -tvf app.jar I can see that the files are inside the jar on the right folder:
/static/images/head.png for example, but calling: http://localhost:8080/images/head.png, all I get is a 404

Any ideas why spring-boot is not finding this? (I’m using 1.1.4 BTW)

26 Answers
26

Leave a Comment