Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I store static resources when I build spring-boot app by gradle?

I've found samples that stores static files in /src/main/webapp/ and /src/main/resources/static/. What's the difference and what's the best place to store static files in spring-boot app?

like image 961
fedor.belov Avatar asked Dec 24 '13 08:12

fedor.belov


People also ask

How do spring boots use static resources?

Using Spring BootSpring Boot comes with a pre-configured implementation of ResourceHttpRequestHandler to facilitate serving static resources. By default, this handler serves static content from any of the /static, /public, /resources, and /META-INF/resources directories that are on the classpath.

What is bootJar in gradle?

bootJar on the other hand is a specific task added by Spring Boot Gradle plugin that, when the java plugin is present, attaches itself to the assemble lifecycle task. The assemble task is automatically configured to depend upon the bootJar task so running assemble (or build ) will also run the bootJar task.


1 Answers

If your resources are in src/main/webapp that suggests you are building a WAR archive. And for a JAR src/main/resources is more appropriate (eg in /static if it's a boot app). It's up to you though if you want to put stuff in non standard places - you just have to configure the build system to understand what you mean.

like image 168
Dave Syer Avatar answered Oct 12 '22 14:10

Dave Syer