0

Hi I am new to springboot, i have create a component class which is auto wired in a service class, i have a DAO class implemented when i try to autowired in to component class i am getting NullPointerException, am able to user the method of DAO if in do it in service class

My application is structured as follows:

Service class

@Service
public class MyService implements IMyService{

    @Autowired
    IMyComponent myComp;

    @Override
    public sFunc(){
     myComp.cFunc();
    }

}

Component class

@Component
public class MyComponent implements IMyComponent{

    @Autowired
    IMyDAO mydao;

    @Override
    public cFunc(){
     mydao.daoFunc();
    }
}

DAO class

@Transactional
@Repository
public class MyDAO implements IMyDAO{

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public daoFunc(){
      sysout("here");
    }
}

Is this flow correct did?

0 Answers0