简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM