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.