I am trying to add jQuery to my Boot app using Webjars. I got the inspiration from this tutorial: http://spring.io/blog/2014/01/03/utilizing-webjars-in-spring-boot
In my pom.xml I have added:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>2.1.1</version>
</dependency>
In my html file (using ThymeLeaf for my template engine - not sure if this matters) I have the following:
<script src="webjars/jquery/2.1.1/jquery.min.js"></script>
The file does not load. I have tried both src="webjars...." and src="/webjars...".
I can see the jar in the Maven dependancies listed in my project. When I explore this jar I can see META-INF/resources/webjars/jquery/2.1.1/jquery.min.js. Based on how I understand Boot looks for resources, I think it should find this.
Anyone see this sort of behavior? Any tips on how to trouble shoot it?
This works for me:
<script src="/webjars/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>
Are you sure it's actually on the classpath at runtime? Are you running an app with a context path (i.e. not serving assets from "/")?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With