0
package com.example.demo.dataAccess;

import com.example.demo.Repositories.CommonUserRepo;
import com.example.demo.Repositories.studentUserRepo;
import com.example.demo.secureLogins.commonUser;
import com.example.demo.users.StudentUser;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;


@Component  

public class studentDataAccess {

    @Autowired
    private studentUserRepo strepo;
    @Autowired
    private CommonUserRepo cRepo;


    public void create(StudentUser studentUser,commonUser cUser) throws Exception{
        strepo.save(studentUser);
        cRepo.save(cUser);
    }
    
}

this was my class where i autowired my repo.

Below is my repository package com.example.demo.Repositories;

import com.example.demo.users.StudentUser;

import org.springframework.data.jpa.repository.JpaRepository;

import org.springframework.stereotype.Repository;


@Repository

public interface studentUserRepo extends JpaRepository<StudentUser,String> {
    
}

i have autowired my repository but when run it says strrepo is null cannot invoke .save(Object) please help me what am i doing wrong as i am new to spring boot and this is my first time using spring boot.

niks
  • 3
  • 1

0 Answers0