如何解决JAR之间的循环依赖?

发布于 2024-12-03 09:09:10 字数 222 浏览 3 评论 0原文

我正在开发一个包含大量 JAR 的大项目,并且肯定不存在任何文档! :(

为了确保应用程序中没有内存泄漏,我使用 JBoss Tattletale 来检查Jars 之间的循环依赖关系,不幸的是我发现了很多。

您能指导我如何解决 JAR 之间的循环依赖关系吗

I am working on a big project with a lot of JARs and for sure no documentation exists!! :(

To ensure that there is no memory leakage in the application, I've used JBoss Tattletale to check for circular dependencies between Jars and unfortunately I have found many.

Can you please guide me on how to solve circular dependencies between JARs??

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暮色兮凉城 2024-12-10 09:09:10

您可以通过依赖倒置来打破依赖。为了避免和解决循环依赖,设计分层架构很有帮助。

也就是说,循环依赖不会导致内存泄漏。但打破循环依赖有很多积极的影响,主要是模块化。这不仅增加了灵活性,还有助于检查和解决问题,包括内存泄漏。

如果您不破坏循环依赖包,那么它们的行为与一个大型整体包非常相似!

You can break dependencies by dependency inversion. To avoid and resolve circular dependencies, it helps to design a tiered architecture.

That said, the circular dependencies do not cause memory leakage. But breaking circular dependencies has a lot of positive effects, mainly modularization. This not only increases flexibility, but also helps in checking and resolving problems, memory leaks included.

If you do not break circular dependent packages, those behave very similar to one large, monolithic package!

倥絔 2024-12-10 09:09:10

除了使用接口之外,您通常还可以通过在 jar/包之间移动类来进行结构改进。分解臃肿的类,以便更容易地将共同的职责组合在一起,可以帮助完成这个过程。有几种商业可视化/重组工具可以帮助解决这个问题。

As well as using interfaces, you can often make structural improvements by moving classes between jars/packages. Breaking up fat classes so that common responsibilities can be more easily grouped together can help with this process. There are several commercial visualization/restructuring tools to help with this.

美男兮 2024-12-10 09:09:10

如果内存泄漏,您的意思是消耗了超过必要的内存我的罐子太胖了,那么,您可能想要调查Proguard

我正在创建大型 Maven 项目,对许多库有许多依赖项,而这些库本身又对其他库有依赖项。但是,我并没有使用所有库中的所有代码。 Proguard 基本上帮助我修剪和删除所有不必要的代码。

它确实是一个干净的工具,可以为我完成这项工作。我创建了一个包含所有依赖项的巨大胖罐子,在代码中配置入口点,然后它缩小了所有内容。

If by memory leakage, you mean more memory than necessary is consumed or my jar(s) is(are) too fat, then, you may want to investigate Proguard.

I am creating large maven projects, with many dependencies on many libraries, which themselves have dependencies to other libraries. However, I am not using all the code in all libraries. Proguard basically helps me trim and remove all unnecessary code.

It is really a clean tool doing the job for me. I create a huge fat jar with all my dependencies, configure my entry points in my code and then it shrinks everything.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文