I have serices like below
@Service
public class A {
public B data() {
InterfaceA B = (codition) ? new B1() : new B2();
B.check();
}
}
@Service
public class B1 {
@Autowired
private B1Repo b1repo;//repository
public B1 check() {
b1repo.find();
}
}
When I run service A.data()
process I'm getting that b1repo
as null. The repository is not auto-wiring since I'm using new
keyword.
I have checked the below issue
related_issue
But It didnt help me solve the issue