MS-Lesson2: Spring Boot Crash Course
-> tracer google.com veya traceroute google.com
google unvanina qeder olan marwrutu gosterir
-> AllArgConstructor butun fieldler ucun constructor yaradir
-> RequiredArgConstructor yalniz final fieldler ucun constructor yaradir
-> Bir intefacenin bir nece implementationu olduqda, constructora clasin adini gonderdikde hemin obyekti inject edir.
-> @Qualifier annotationu da bunu hell edir. Bu zaman clasin adini yenede kicik yazmaliyiq.
-> @Scope beanleri singleton veya prototype yaratmaq ucun istifade olunur
-> @Lazy
package az.ingress.ms14.service;
import org.springframework.stereotype.Service;
@Service
public class A {
private final B b;
public A(B b) {
this.b = b;
}
}
package az.ingress.ms14.service;
import org.springframework.stereotype.Service;
@Service
public class B {
private final A a;
public B(A a) {
this.a = a;
}
}
Bu zaman rekursiya yaranir. Bu da problemdir.
@Lazy annotasiyasini yazdiqda A klasinin obyektine ehtiyac duyulmadigi teqdirde onu cagirmir.
package az.ingress.ms14.service;
import org.springframework.stereotype.Service;
@Service
public class A {
private final B b;
public A(B b) {
this.b = b;
}
}
package az.ingress.ms14.service;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@Service
public class B {
private final A a;
public B(@Lazy A a) {
this.a = a;
}
}
Комментарии
Отправить комментарий