简体   繁体   English

如果不同的 jars 在插件 Z68995FCBF432492D15484D04A9D2AC4 中具有相同的 class 名称,则访问 class

[英]Accessing class if different jars having same class name in plugin jar

I have a requirement for the below scenario:我对以下场景有要求:

I am using plugin and It has 3 jar versions.我正在使用插件,它有 3 个 jar 版本。 All the jars are needed in my requirements.我的要求中需要所有 jars。 But the issue is in all the jars the package name and class name are same (But the content of the class is different for different version).但问题在于所有 jars package 名称和 class 名称相同(但 ZA2F2Z21ED4F8EBC40AB61DZ 的内容不同,版本不同)。 So, It's giving me error Could not resolve the type while I am trying to use the class.所以,当我尝试使用 class 时,它给了我错误无法解析类型。

Can anyone suggest me how to resolve the problem.谁能建议我如何解决这个问题。

Thank You!!!谢谢你!!!

The only way to do this is to use multiple class loaders and load each version of plugin.jar using a different UrlClassLoader.唯一的方法是使用多个 class 加载器并使用不同的 UrlClassLoader 加载每个版本的 plugin.jar。

For more information on how to load jar at runtime using UrlClassLoader, refer to How should I load Jars dynamically at runtime?有关如何使用 UrlClassLoader 在运行时加载 jar 的更多信息,请参阅如何在运行时动态加载 Jars?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM