The Problem log in eclipse shows "A cycle was detected in the build path of the project ...." Any idea what to do to get rid of these cyclic dependencies? I don't know which projects are dependent on each other.
A cyclic dependency is an indication of a design or modeling problem in your software. Although you can construct your object graph by using property injection, you will ignore the root cause and add another problem: property injection causes Temporal Coupling. Instead, the solution is to look at the design closely.
A simple way to break the cycle is by telling Spring to initialize one of the beans lazily. So, instead of fully initializing the bean, it will create a proxy to inject it into the other bean. The injected bean will only be fully created when it's first needed.
Cyclic dependencies between components inhibit understanding, testing, and reuse (you need to understand both components to use either). This makes the system less maintainable because understanding the code is harder. Lack of understanding makes changes harder and more error-prone.
Maven does not allow cyclic dependencies between projects, because otherwise it is not clear which project to build first. So you need to get rid of this cycle. One solution is the one you already mentioned, to create another project.
You can adjust the circular dependencies severity in eclipse:
Preferences > Java > Compiler > Building > Build path problems > Circular dependencies
There are three ways to remove cyclic dependency between projects in eclipse,
1.Go to project-> java compiler-> building -> Enable project specific settings.
Select build path problems and give warning as option for circular dependency.
2.Go to project->java build path. In projects tab, select the project and remove.
3.Go to your META-INF folder, open MANIFEST.MF. In your MANIFEST.MF view tab, you can see the cyclic dependent project in "Import package:" column.
Remove the project from the column.
The first option does not really resolve the error. The second and the third option are the right way to resolve this dependency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With