0
 @Resource
 EmployeeDAO empdao;

where empdao is:

@Repository
public interface EmployeeDAO extends JpaRepository <Employee , Long>{

   System.out.println("Enabling jpa1");

   @Override
   public Optional<Employee> findById(Long id);

   @Override
   public List<Employee> findAll();
   ........

}

This does not work. While it is working with @Autowired

The Guest
  • 698
  • 11
  • 27
Yogesh Kumar Gupta
  • 163
  • 1
  • 3
  • 13
  • See this: https://stackoverflow.com/questions/4093504/resource-vs-autowired – The Guest Mar 01 '19 at 20:20
  • I have seen that post and the bean is actually injected. If interface has any default method it will be called without any issue. How ever if we are calling methods from jpa repo ,like "findbyid" ,we will get the null pointer exception. Looks like the spring does not support the @Resource bean injection with jpa enabled. – Yogesh Kumar Gupta Mar 02 '19 at 13:03

0 Answers0