Reputation: 167
When we get error:
Cannot invoke "" because this.""
For example:
Cannot invoke "com.saran.sprndatajpa.config.CustomerRepository.findAll()" because "this.customerRepository" is null
How do I resolve this error?
Upvotes: 2
Views: 4588
Reputation: 167
This error occurs as the required bean is not autowired. In this case, if we autowire customerRepository
, the problem will be resolved:
@Autowired
CustomerRepository customerRepository ;
Upvotes: 2
Reputation: 1
CustomerRepository is not injected as a Bean that's why this exception is coming. If CustomerRepository is Interface then try with constructor based bean injection. In my case, it worked when Constructor was invoked.
Upvotes: 0