我在學習JPA。試圖建立該項目,但趕上錯誤:Hibernate-JPA。 javax.persistence.PersistenceException
Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/HomeProject-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build EntityManagerFactory
誰有這方面的經驗,請幫助我。 我的背景:
<context:property-placeholder location="file:${hp.ini}"/>
<!-- Включаем опцию использования конфигурационных аннотаций (@Annotation-based configuration)-->
<context:annotation-config/>
<tx:annotation-driven/>
<jpa:repositories base-package="com.kuzmenko.homeproject.repo"/>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClass}"
p:url="${jdbc.url}"
p:username="${jdbc.user}"
p:password="${jdbc.password}"/>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceProviderClass" value="org.hibernate.ejb.HibernatePersistence"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.kuzmenko.homeproject.domain</value>
</list>
</property>
</bean>
我認爲我應該創建的persistence.xml。如何生成它?我應該添加哪些依賴關係?