Reputation: 2148
I've followed the guide here for turning a "hello, world" level Spring Boot app to a war file. I can run this war like a jar and it will return the simple template.
What I don't understand is why I can't access a main.css file I've created. I've placed it in the resources directory under "static/css/main.css" and according to the docs here Spring Boot will automatically server files under "resources", "static", "public", and "META-INF/resources". However, when I build my war file and run it I can't query those files in the browser (like http://localhost:8080/static/css/main.css
). Have a missed a step? If I peek into the created war file I see the "static" directory in "WEBINF/classes" right beside the "templates" directory and the directory holding my application.
Upvotes: 0
Views: 1157
Reputation: 116091
Files in src/main/resources/static
are served from /
so you don't need static
in the path. You CSS file should be available from http://localhost:8080/css/main.css
Upvotes: 4