web项目访问jar内部的静态资源
source link: https://blog.51cto.com/u_14482423/5558243
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
web项目访问jar内部的静态资源
原创一、实现原理
在Servlet3协议规范中,包含在JAR文件/META-INFO/resources/
路径下的资源可以直接访问。
二、举例说明
如下图所示,是我新建的一个Spring Boot Starter项目:zimug-minitor-threadpool,用于实现可配置、可观测的线程池。其中pool.html
就是线程池运行状态的监控页面。放在如下图所示的位置。
位置放置正确之后,将项目打包。我的最终打包结果是zimug-minitor-threadpool-1.0.jar
。当一个Spring Boot项目需要引用这个jar包的时候,直接通过maven坐标引入即可。访问服务的/pool.html
即可获取当前SpringBoot服务的线程池配置信息,以及运行时状态信息。
说明按照这种方式,访问jar包里面的静态资源是可行的。
如果您觉得有帮助,期待您的关注、转发,您的支持是我不接的创作动力!欢迎关注公众号:字母哥杂谈
- 赞
- 收藏
- 评论
- 分享
- 举报
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK