我正在使用 Spring、Hibernate 创建一个 Web 应用程序 (MVC),当我在服务器上运行它时收到错误(使用 Glassfish v4.1)。以下是错误:
cannot Deploy project1 deploy is failing=Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'dataSource1' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource1' is defined. Please see server.log for more details.
如何修复此错误?提前致谢。
这是“applicationContext.xml”文件:
这是“persistence.xml”文件:
最佳答案
就像@M。 Deinum 评论道,您需要确保定义了一个名为“dataSource1”且类型为 javax.sql.DataSource 的 bean,与此类似:
<bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource">
<property name="URL" value="${url}" />
<property name="user" value="${username}"/>
<property name="password" value="${password}"/>
</property>
</bean>
关于java - Spring、Hibernate、MVC 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27911167/