Skip to content

Simple Maven project with Spring Boot to demonstrate solutions of circular dependecy problem.

License

Notifications You must be signed in to change notification settings

Interes-Group/spring-course-circular-dependency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Course - Circular dependency

Java CI with Maven License MIT Java 1.8

Cieľom je oboznámiť sa s problémom kruhovej závislosti. Dokumentácia je dostupná na docs.spring.io

Problém

Projekt demonštruje problém cyklickej závislosti.

Cyklická závislosť vzniká napríklad pri nasledujúcom kóde dvoch spring komponentov:

public class ServiceA {
    private final String secret = "A";
    private final ServiceB serviceB;
 
    public String getSecret() {
        return secret;
    }
   
    public String getCombinedSecrets() {
        return secret + serviceB.getSecret();
    }
}
public class ServiceB {
    private final String secret = "B";
    private final ServiceA serviceA;
 
    public String getSecret() {
        return secret;
    }
 
    public String getCombinedSecrets() {
        return secret + serviceA.getSecret();
    }
}

Riešenie

  • Lazy loading závislosti
  • Setter-based dependency injection

Build

Maven build: mvn clean compile package

About

Simple Maven project with Spring Boot to demonstrate solutions of circular dependecy problem.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages