Web Jars

Submitted by Dickens A S on Mon, 03/16/2020 - 10:49

Web Jars is a dependency management technique which reduces the leraning curve of the developer to use single dependency management system to manage the versions of JavaScript libraries or other non-maven-standard libraries which has other then java code

For Example: i you want to add jQuery into your spring boot project, in the past you need to put that in the static folder manually of you need to use tools like bower to download it inside the static folder

but now you don't have to do that, you can use same pom.xml or build.gradle and specify the webjar dependency

Gradle Example

compile group: 'org.webjars', name: 'jquery', version: '3.4.1'

Maven Example


then in your spring boot project you have to add a URL mapping common to all webjars as below

class WebConfig: WebMvcConfigurer {
   override fun addResourceHandlers(registry: ResourceHandlerRegistry) {


then to use this in your HTML code you need the below code

<script src="/webjars/jquery/jquery.min.js"></script>

this reduces the manual download of javascript and allows you to maintain due-diligence in your build system


Add new comment