我将我的项目添加到war文件并在jetty服务器中部署它显示以下错误,但它在weblogic服务器中部署意味着它将正常工作。
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory. BeanCreationException: Error creating bean with name 'sampDao': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'testDataPersistence' is defined
XML文件包含
<bean id="testEntityManager"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceProvider">
<bean class="org.hibernate.jpa.HibernatePersistenceProvider" />
</property>
<property name="persistenceUnitName" value="testDataPersistence" />
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.test.samp" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.transaction.jta.platform">org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform</prop>
<prop key="hibernate.id.new_generator_mappings">true</prop>
</props>
</property>
</bean>
java代码
@PersistenceContext(unitName = "testDataPersistence", name = "testEntityManager")
private void setEntityManager(EntityManager em) {
this.em = em;
}