Spring Boot下的静态资源:
1. 类路径文件
/static 、/public、/resources和/META-INF/resources文件下的静态文件直接映射为/,可通过http://localhost:8080/访问。
2. webjar
WebJars are client-side web libraries (e.g. jQuery & Bootstrap) packaged into JAR (Java Archive) files.
main features
Explicitly and easily manage the client-side dependencies in JVM-based web applications
Use JVM-based build tools (e.g. Maven, Gradle, sbt, ...) to download your client-side dependencies
Know which client-side dependencies you are using
Transitive dependencies are automatically resolved and optionally loaded via RequireJS
Deployed on Maven Central
以上webjar信息来源于https://www.webjars.org/.
popular webjar
jquery
Bootstrap
Font Awesome
npm
jQuery UI
AngularJS
i18n-number
……
how to get webjar
以jquery的webjar为例进行加载:
###
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.3.1</version>
</dependency>
该webjar下载到Maven Dependencies中,待其通过mvn:install安装到本地目录后,将本地目录下webjars目录下的静态文件拷贝到src/main/resources下的/META-INF/resources/webjars下,即将这些静态文件映射为/webjars/,可以通过http://localhost:8080/webjars/来访问。