开发者

How to solve circular dependencies between JARs?

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.


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!


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜