Mythul
Mythul

Reputation: 1807

How to update static resources in Spring MVC without rebuilding?

I have a classic Spring MVC project where my resource files are put in the directory:

webapp -- resources -- js

webapp -- resources -- css

I also use:

<!--declare resources-->
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />

My question what do I need to config so that every time I update the css & js files the changes appear when I refresh the page ?

Right now I have to rebuild the project each time a change is made so that the war file is updated.

Upvotes: 0

Views: 1957

Answers (1)

Brian Clozel
Brian Clozel

Reputation: 59056

One solution would be to split your project in two: - a front-end module - a classic war module

This way, you can set up whatever front-end build tool you want to (grunt, gulp, etc) and ship all your optimized in a web JAR as a dependency of your war module.

And of course, this way you can serve resources directly from disk, no need to redeploy your server each time. There's a full example here.

Upvotes: 2

Related Questions