Giriş
Şu satırı dahil ederiz.
Şöyle yaparız.
Şöyle yaparız.
Şu satırı dahil ederiz.
import org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor;
Açıklaması şöyle. Normalde bu bean'i yaratmaya gerek yok.org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor is automatically loaded into App Context by Spring when using annotation based configuration. One of its duties is to search the proper entity EntityManagerFactory that would provide the EntityManager for you @PersistenceContext annotated properties.constructor
If you have multiple EntityManagerFactory beans in you spring config/context and you have @PersistenceContext annotations without a unitName attribute (lets say you are using a framework that comes with such a bean, and you can't touch framework code), you may run into this exception: org.springframework.beans.factory.NoUniqueBeanDefinitionException.
Şöyle yaparız.
@Bean
public PersistenceAnnotationBeanPostProcessor persistenceAnnotationBeanPostProcessor() {
return new PersistenceAnnotationBeanPostProcessor();
}
defaultPersistenceUnitName AlanıŞöyle yaparız.
<bean id="org.springframework.context.annotation.internalPersistenceAnnotationProcessor"
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" >
<property name="defaultPersistenceUnitName" value="entityManagerFactory"/>
</bean>
Hiç yorum yok:
Yorum Gönder