D.S.
D.S.

Reputation: 167

con not invoke "" because this."" is null (or) Cannot invoke "CustomerRepository.findAll()" because "this.customerRepository" is null

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

Answers (2)

D.S.
D.S.

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

Maithili
Maithili

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

Related Questions