使用bytebuddy对springboot 应用进行instrument的时候,会原本正常的springboot 应用有class not found的情况。

网上能看到基本都是说双亲机制导致的问题,有些提供了很复杂的解决方法。

但经过测试发现使用appendToBootstrapClassLoaderSearch 把相关class
导入class path即可,参考代码如下。

 //  instrumentation.appendToSystemClassLoaderSearch(jarFile);
        //spring bott 使用bootStrapClassLoader
        //The agent should take care to ensure that the JAR does not contain any classes or resources other than those to be defined by
        // the bootstrap class loader for the purpose of instrumentation.
       instrumentation.appendToBootstrapClassLoaderSearch(jarFile);
Logo

电影级数字人,免显卡端渲染SDK,十行代码即可调用,工业级demo免费开源下载!

更多推荐