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