首页 > 编程知识 正文

java类加载器有什么用,自定义spring框架

时间:2023-05-06 01:04:21 阅读:11887 作者:2930

spring不管理自己被放在哪里。 所有使用TCCL加载类,但默认情况下TCCL设置为web app类加载器。 这意味着,哪个WebApp APP应用程序调用spring,spring使用该APP应用程序自己的web app类加载器加载bean。 在对线程上下文类加载器的理解(多个案例研究)中详细介绍了这一点。

因此,要使用自定义类加载器加载spring,必须打开线程并将该线程的类加载器设置为自定义类加载器。

publicstringtest((try )/myclassloadercustom为https://blog.csdn.net/QQ _ 32506245/article/details/13059028 myclassloadercustommyclassloadercustom=newmyclassloadercustom (thread.current thread ).getcontextclassloader calllload ncontextctx=newclasspathxmlapplicationcontext (application.XML ) ); testatesta=(testa ) CTX.getbean(com.example.testa ); return testA.getClass ().getClassLoader ) ).toString ); (; futuretaskstringtask=newfuturetask (callable; threadthread=newthread(task; //用于设置线程上下文类加载器thread.setcontextclassloader (myclassloadercustom )的thread.start (; while (! task.isDone (); return task.get (; }catch(exceptione ) { e.printStackTrace ); }返回空值; }参考站点真正了解线程上下文加载器((多案例研究) ) ) ) ) ) ) ) ) ) )。

saturn java热加载(2)资源文件spring logback

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。