You should verify the following:
1) Annotate the UserRepo
with @Repository
.
2) Your spring beans xml file should have in it:
<jpa:repositories base-package="your.repository.package"></jpa:repositories>
3) I'd recommend injecting this type of bean with @Autowired
instead of @Resource
UPDATE
it seems you did my first 3 steps and you're one step ahead now. Now, remember that in Java Config methods names DO matter. Either change emf()
to entityManagerFactory()
(which is more "standard"), or set entity-manager-factory-ref
to emf
. Example:
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws ClassNotFoundException, PropertyVetoException {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource());
emf.setPackagesToScan("my.package");
emf.setJpaVendorAdapter(jpaAdapter());
emf.setJpaProperties(jpaProterties());
return emf;
}