spring 热加载外部jar包

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

想法是,将外部的spring工程jar包在spring启动之后可以热加载进spring容器。遗憾的是到现在为止没有实现。

目前尝试的几种思路:
1、自定义classloader–>加载jar包进JVM–>修改spring的classloader,自定义classloader,ext-classloader的父子关系->将jar包使用注解扫描进入spring->refresh(这步失败了,报java.lang.IllegalStateException: GenericApplicationContext does not support multiple refresh attempts: just call ‘refresh’ once)
classloader父子关系的设定貌似也有问题
2、自定义classloader–>加载jar包进JVM–>遍历所有的class并将其加入spring–>调用
(以上都是成功的,但加入spring时可能会破坏spring的规则导致错误,而且载入的mybatis也需要处理)

参考:
http://sheungxin.iteye.com/blog/2352833
https://blog.csdn.net/chjttony/article/details/6301523

猜你喜欢

转载自blog.csdn.net/u011649691/article/details/82769984