214°

Spring、SpringMVC、Hibernate整合

1.整合Spring、SpringMVC
2.整合Spring、Hernate
3.配置web.xml文件
4.配置Tomcat,并且配置为热部署
5.在此不过多介绍Spring、SpringMVC整合
6.Spring与Hibernate整合关键代码如下
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="com.example.ssh.orm"/>
<!--Hibernate基本配置-->
<property name="hibernateProperties">
<props>
<!--根据实体类自动生成数据库表-->
<prop key="hibernate.hbm2ddl.auto">${ssm.hibernate.hbm2ddl.auto}</prop>
<!--方言-->
<prop key="hibernate.dialect">${ssm.hibernate.dialect}</prop>
<!--显示SQl语句-->
<prop key="hibernate.show_sql">${ssm.hibernate.show_sql}</prop>
<!--格式化SQL-->
<prop key="hibernate.format_sql">${ssm.hibernate.format_sql}</prop>
</props>
</property>
</bean>
<!--事务管理器("声明式事务")-->
<bean id="txManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!--事务用注解来配置,并扫描-->
<tx:annotation-driven transaction-manager="txManager"/>
如有疑惑请联系我!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

原文链接:https://www.cnblogs.com/2070393244com/p/9998047.html

全部评论: 0

    我有话说: