3

Hello dear Stack Overflow community,

I have a Spring Boot web app that was previously packaged as a WAR file, my static content was placed inside a webapps/resources folder ( apart from thymeleaf templates that were placed inside resources/templates ).

After I converted my project to a JAR I was expecting that my app won't be able to find the static resources, as I've done some research on that and I found out that when packaged as JAR the webapps/resources folder isn't by default in the classpath.

Oddly, Spring was able to locate my static resources and everything works fine.

So the first part of my question is why Spring can find the static resources without any extra configuration?

And the second part is do you think that removing the webapps folder completely and placing the static resources in an other location ( e.g. resources/static ) is a better approach?


NOTE #1: I use no configuration at all for specifying the location of static content inside my app ( I just use the defaults ), so it seems quite unexpected that spring was able to find these files.


NOTE #2: I reference the static content via relative paths in my thymeleaf templates.


Thanks in advance for your time and answers, Spiros.

Brian Clozel
59.7k15 gold badges180 silver badges184 bronze badges
asked Jun 18, 2023 at 14:17

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.