springboot使用webjars加载资源

实践

导入依赖

首先我们进入webjars(https://www.webjars.org/)网站,也可以自行百度搜索webjars,进入网站后,找到需要的资源的maven依赖

springboot使用webjars加载资源_第1张图片复制相关的依赖,我这里演示,使用jQuery的3.4.1版本

    
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.webjars
            jquery
            3.4.1
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
            
                
                    org.junit.vintage
                    junit-vintage-engine
                
            
        
    

启动项目,在浏览器中输入:

http://localhost:8080/webjars/jquery/3.4.1/jquery.js

就可以对资源进行访问了
springboot使用webjars加载资源_第2张图片在HTML中引用的路径为

  

如有不足之处,请指出,谢谢!
每天进步一点点。

你可能感兴趣的:(后端)