0

I have a Spring Boot App with a Vaadin Crud and database connection. If I want to inject the repository for the corresponding entity with @AutoWired I get a NullPointerException. I have already checked many reasons, but found nothing. What am I missing here?

There is a similiar problem but it was solved because the component was initialized manually but this is not the case here.

Here is my repository class

@Repository
public interface CombizRepository extends JpaRepository<Combiz, Integer> {

}

The class is annotated with @Repository so it's a spring component.

Here is my DataProvider class where I wire the repository:

public class CombizDataProvider extends AbstractBackEndDataProvider<Combiz, CrudFilter> {

  @Autowired
  CombizRepository repository;

  @Override
  protected Stream<Combiz> fetchFromBackEnd(Query<Combiz, CrudFilter> query) {
    return repository.findAll().stream();
  }

  @Override
  protected int sizeInBackEnd(Query<Combiz, CrudFilter> query) {
    return (int) fetchFromBackEnd(query).count();
  }

  public void persist(Combiz item) {
    repository.save(item);
  }

  public void delete(Combiz item) {
    repository.delete(item);
  }
}

I thank you in advance and hope that someone can explain what I missed here.

lsiem
  • 73
  • 7
  • add @service annotation to CombizDataProvider – archzi Oct 13 '20 at 10:59
  • Thanks for the hint. I have added the annotation. Then I was confronted with several other errors, which I could solve all of them until the same error occurred again. I still have the NullPointerException. – lsiem Oct 13 '20 at 11:45
  • please take a look the duplicated question that mention on the top and i guess your will solve your problem by yourself! – archzi Oct 13 '20 at 17:04

0 Answers0