Thursday, July 16, 2015

Apply `WebJarsResourceResolver` in Spring Boot

To apply `WebJarsResourceResolver` in Spring Boot,

add the following property to `application.properties`:

spring.resources.chain.enabled:true

and add the following dependency to `build.gradle`:

    compile("org.webjars:webjars-locator:0.26")
    compile("org.webjars:jquery:2.1.4")

Now you can use jQuery as follows in Thymeleaf templates:

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

No comments:

Post a Comment