栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Spring + Hibernate + JPA [关闭]

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Spring + Hibernate + JPA [关闭]

我刚刚花了最后几个星期尝试建立相同类型的项目。

您确实需要一个persistence.xml文件,它属于meta-INF

这是我的持久性Spring bean文件的示例:

<beans  xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns:tx="http://www.springframework.org/schema/tx"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"><context:property-placeholder location="/WEB-INF/config.properties" />    <tx:annotation-driven /><bean id="transactionManager" >     <property name="entityManagerFactory" ref="entityManagerFactory" /></bean><bean id="jpaTemplate" >     <property name="entityManagerFactory" ref="entityManagerFactory" /></bean><bean id="dataSource" >     <property name="driverClassName" value="${db.driver}" />     <property name="url" value="${db.url}" />     <property name="username" value="${db.user}" />     <property name="password" value="${db.password}" /></bean><bean id="entityManagerFactory" >     <property name="persistenceUnitName" value="whatisayis" />    <property name="dataSource" ref="dataSource" />    <property name="jpaVendorAdapter">         <bean >  <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" />  <property name="showSql" value="true" />  <property name="generateDdl" value="true" />        </bean>     </property></bean><bean id="leDAO" >    <property name="jpaTemplate" ref="jpaTemplate" /></bean> <bean id="sampleDAO" >    <property name="jpaTemplate" ref="jpaTemplate" /></bean>    <bean id="tagDAO" >    <property name="jpaTemplate" ref="jpaTemplate" /></bean></beans>

另外,我正在使用Maven拉入我需要的spring3和hibernate依赖关系。

编辑:对于学习资源,我强烈推荐Gary Mac撰写的“ Spring Recipes A Problem-Solution
Approach”(http://www.apress.com/book/view/9781590599792)。这是我读过的最好的技术书籍之一,它肯定会帮助您使用Spring
/ JPA / Hibernate入门和运行。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/393164.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号