@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(){
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(datasource());
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setJpaProperties(properties());
em.setPersistenceUnitName("JPA_PU");
em.setPackagesToScan("com.test.entity");
return em;
}
从我的持久性配置中的bean声明中注入了这个 豆进入这个
@PersistenceContext(unitName = "JPA_PU")
private EntityManager em;
但不是
@Autowired
private EntityManagerFactory emf;