Spring boot的Webjars

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/nangeali/article/details/82344791

Webjars

Spring boot
以jar包的方式,引入静态资源

创建Web工程
WebMvcAutoConfiguration

Ctrl+Shift+R
搜索addResourceHandlers
这里写图片描述
/webjars/**
所有/webjars/**
都去classpath:/META-INF/resources/webjars/找资源

网址
https://www.webjars.org/
这里写图片描述
比如
引入jQuery
Pom文件添加

<!‐‐引入jquery‐webjar‐‐>
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>jquery</artifactId>
    <version>3.3.1</version>
</dependency>

External Libraries
工程依赖
这里写图片描述
访问资源
在访问的时候
只需要写webjars下面资源的名称即可

localhost:8080/webjars/jquery/3.3.1/jquery.js

猜你喜欢

转载自blog.csdn.net/nangeali/article/details/82344791