Webjar是什么

WebJars是打包到JAR(Java Archive)文件中的客户端Web库(例如jQuery和Bootstrap)。
  • 在基于JVM的Web应用程序中显式轻松地管理客户端依赖项
  • 使用基于JVM的构建工具(例如Maven,Gradle,sbt,...)来下载客户端依赖项
  • 了解您正在使用的客户端依赖项
  • 传递依赖关系会自动解析,并可选择通过RequireJS加载
  • 部署在Maven Central上
  • 公共CDN,慷慨提供: 22185335_NMFg.png

 

  • Pom.xml

            <!-- https://mvnrepository.com/artifact/org.webjars/webjars-locator -->
    <dependency>
                <groupId>org.webjars</groupId>
                <artifactId>webjars-locator</artifactId>
                <version>0.32-1</version>
    </dependency>
     <dependency>
                <groupId>org.webjars</groupId>
                <artifactId>bootstrap</artifactId>
                <version>3.3.7-1</version>
    </dependency>
    <dependency>
                <groupId>org.webjars</groupId>
                <artifactId>jquery</artifactId>
                <version>3.2.1</version>
    </dependency>
    
    • webjars-locator 包的作用是省略 webjar 的版本。比如对于请求 http://localhost:8080/webjars/jquery/3.1.0/jquery.js省略版本号 3.2.1 直接使用http://localhost:8080/webjars/jquery/jquery.js也可访问。
  • Html 页面引用资源文件

    原:

    <link rel="stylesheet" href="/css/bootstrap.min.css"/>
    

    现:

    <link rel="stylesheet" href="/webjars/bootstrap/css/bootstrap.min.css"/>
    
  • 其他资源文件引用方式:cdn加速服务

<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

 

 

转载于:https://my.oschina.net/wuweixiang/blog/1932362

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值