The Web front end uses more and more JS or CSS, such as jquery, Backbone.js and Bootstrap. In general, we are copying these Web resources into the directory of Java, through manual management, this way easily lead to file confusion, version inconsistency and other issues.
Webjars is a jar package that packages these generic web front-end resources into Java, and then manages them with MAVEN tools to ensure that these Web resource versions are unique and easy to upgrade. About Webjars Resources, there is a dedicated website http://www.webjars.org/, we can go to this site to find their own resources, in their own projects to add to Maven dependency, you can directly use these resources.
In my project experiment, using SPINGMVC for front-end management, which used bootstrap as the skeleton of the foreground CSS, used the bootstrap resources of Webjars.
1, first in the project's pom dependency to add to the bootstrap Webjars dependency
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.1.0</version>
</dependency>
2. In spring's configuration file, redirect access to/webjars to/meta-inf/resources/webjars/
<!--uses webjars so Javascript and CSS Libs can be declared as Maven dependencies (Bootstrap, jQuery ...)--
<mvc:resources mapping= "/webjars/**" location= "classpath:/meta-inf/resources/webjars/"/>
3, introduced in the page CSS, JS file, here is an inconvenient place to remember the version number
<link rel= 'stylesheet ' href='/webjars/bootstrap/3.1.0/css/bootstrap.min.css ' >
In Webjars's website, about three kinds of application webjars, respectively, NPM Webjars, Bower webjars, classic Webjars, my above method belongs to the classic Webjars way, the other two ways have not been applied , a follow-up study is needed .....
Using Webjar to manage CSS, JavaScript files