누군가가 spring-data-jpa와 java-ee 응용 프로그램을 통합하려고 했습니까? glassfish3을 응용 프로그램 컨테이너로 사용하고 있습니다. CDI 환경에서 Spring-Data-JPA?
나는 공식 스프링 데이터 JPA 튜토리얼을 따라 클래스 생성 :public class EntityManagerFactoryProducer {
@Produces
@ApplicationScoped
public EntityManagerFactory createEntityManagerFactory() {
return Persistence.createEntityManagerFactory("myPU");
}
public void close(@Disposes EntityManagerFactory entityManagerFactory) {
entityManagerFactory.close();
}
@Produces
@RequestScoped
public EntityManager createEntityManager(EntityManagerFactory entityManagerFactory) {
return entityManagerFactory.createEntityManager();
}
public void close(@Disposes EntityManager entityManager) {
entityManager.close();
}
}
를하지만 내 응용 프로그램을 배포 할 때, 나는 예외 받고 있어요 :
Error occurred during deployment: Exception while preparing the app : Could not resolve a persistence unit corresponding to the persistence-context-ref-name [org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean/entityManager] in the scope of the module called [App]. Please verify your application.. Please see server.log for more details.
Command deploy failed.
무엇 내가 빠졌어? 또 다른 설정 파일이나 xml 파일을 가져야하나요?
나는 문제는 당신이 당신의 persistence.xml에 선언 된 이름 "myPU"와 퍼시스턴스 유닛을하지 않아도 될 것 같아요. 그러나 나는 이것이 올바른 접근이라고 생각하지 않는다. 자세한 내용은 내 대답을 참조하십시오. – Gandalf
PU가 적절하게 선언되었습니다. – slnowak