Automates WebJars version handling for Spring Boot applications when using LiveReload and Grunt build stack.

spring-boot, spring, maven, livereload, webjars, version
npm install webjarver@1.0.1



This package is intended to be used in projects having a Java backend that use Maven for build and WebJars to handle Javascript libraries. WebJars pack Javascript libraries in paths which include the version number of the library like this:

<script type="text/javascript" src="webjars/angularjs/1.3.14/angular.min.js"></script>

It's also necessary to have the version number in the pom dependency:


This setup allows to run a Grunt server with Livereload and a proxy during development, but requires to keep the version numbers in at least two diferent files.

To avoid problems with unsynchronized version numbers, I choose to let Maven handle it. Version numbers are written as properties in the pom and Maven resource filtering takes care of replacing their references in HTML files that reference the libraries.

Dependencies in pom.xml are written like this:



The Javascript library can be referenced as such:

<script type="text/javascript" src="webjars/angularjs/${angularjs.version}/angular.min.js"></script>

It also necessary to include a filtering configuration in pom.xml. This example assumes that webapp static resources are at src/main/resources/public following one of Spring Boot's conventions:



Install like any other npm package:

npm install webjarver


In Gruntfile. js, the middleware property of livereload middleware function should load pom.xml and insert WebJarVer in the middleware array.

Here is an example:

	connect : {
		livereload : {
			options : {
				middleware : function(connect) {
					var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;

					// Load webjarver library using RequireJS
					var webjarver = require('webjarver');

					// Load pom.xml passing its full path.
					webjarver.loadPom(__dirname + '/pom.xml');

					return [

						// Load WebJarVer middleware. __It must be inserted after Livereload's livereloadSnippet.__


  1. Convert into a Grunt task to reload version numbers when watch detects a pom.xml change.
  2. Add a task to integrate into Grunt build.

Change Log

  • 1.0.0 - initial release. Connect middleware to be used with LiveReload.