如何在persistence.xml文件中配置数据源?

时间:2014-04-23 10:19:11

标签: spring hibernate jpa

这个问题的答案对我解决上一个问题非常有帮助。

here.

我正在尝试使用简单的Spring-MVC(带JPA)应用程序。我想仅在persistence.xml文件中包含所有必需的连接值。在我的应用程序中,只有2个XMl文件。

1)web.xml和2)persistence.xml

请检查我之前的问题( here.)是否有错误和persistence.xml文件。

我在网上搜索但没有得到正确答案。 请帮我。非常感谢你提前。

1 个答案:

答案 0 :(得分:0)

如果您使用的是Spring / springMVC,那么您只需要在spring应用程序上下文xml文件中配置数据源。 persistence.xml中的所有内容都应放在spring应用程序上下文xml中。因为spring是管理hibernate的核心基础框架。

选中此http://viralpatel.net/blogs/spring3-mvc-hibernate-maven-tutorial-eclipse-example/

在此示例中,它在spring-servlet.xml中配置