【发布时间】:2012-05-30 20:55:57
【问题描述】:
我目前正在学习 EclipseLink 和 Spring 3.0 MVC:
我使用 EclipseLink 编写了一个简单的独立应用程序:它使用 META-INF/persistence.xml 文件并从 mysql 数据库读取和写入数据。
我还在 apache tomcat 下使用 Spring3 MVC 编写了一个简单的“HelloWorld”应用程序。它基于以下教程:http://www.mkyong.com/spring-mvc/spring-3-rest-hello-world-example
现在,我应该如何链接这两种技术?据我了解http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch14s06.html 我需要创建一个 LocalContainerEntityManagerFactoryBean:
<bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="someDataSource"/>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
</property>
</bean>
但是什么是“someDataSource”?我应该使用像 http://commons.apache.org/dbcp/ 这样的另一个库吗?那么eclipselink应该怎么做呢?
一旦 JPA 配置完成,我应该如何从我的 spring Controller 访问它?
谢谢
【问题讨论】:
-
Here 有 Spring + JPA (Hibernate) 示例,您可能会觉得它很有帮助。
标签: java jpa spring-mvc configuration eclipselink