Spring整合Hibernate配置使用hibernate.cfg.xml文件.docVIP

  • 7
  • 0
  • 约2.82千字
  • 约 5页
  • 2017-07-29 发布于浙江
  • 举报

Spring整合Hibernate配置使用hibernate.cfg.xml文件.doc

Spring整合Hibernate配置使用hibernate.cfg.xml文件

? Spring整合Hibernate配置(使用hibernate.cfg.xml文件)2011-09-23 19:50?2177人阅读?评论(0)?收藏?举报 本文主要记录spring整合hibernate的时候,直接使用hibernate.cfg.xml文件注入SessionFactory,applicationContext.xml文件配置如下: ?xml version=1.0 encoding=UTF-8? beans xmlns=/schema/beans xmlns:xsi=/2001/XMLSchema-instance xmlns:aop=/schema/aop xsi:schemaLocation= /schema/beans /schema/beans/spring-beans-3.0.xsd /schema/aop /schema/aop/spring-aop-3.0.xsd bean id=sessionFactory class=org.springframework.orm.hibernate3.LocalSessionFactoryBean property name=configLocations valueclasspath:hibernate.cfg.xml/value /property /bean bean id=userDao class=com.dao.impl.UserDaoImpl property name=sessionFactory ref=sessionFactory/property /bean bean id=userService class=com.service.UserService property name=userDao ref=userDao/property /bean /beans hibernate.cfg.xml配置文件如下:?xml version=1.0 encoding=utf-8? !DOCTYPE hibernate-configuration PUBLIC -//Hibernate/Hibernate Configuration DTD 3.0//EN /hibernate-configuration-3.0.dtd hibernate-configuration session-factory !-- Database connection settings -- property name=connection.driver_classcom.mysql.jdbc.Driver/property property name=connection.urljdbc:mysql://localhost:3306/hibernate/property property name=connection.usernameroot/property property name=connection.password***/property !-- JDBC connection pool (use the built-in) -- property name=connection.pool_size10/property !-- SQL dialect -- property name=dialectorg.hibernate.dialect.MySQLDialect/property !-- Enable Hibernates automatic session context management -- property name=current_session_context_classthread/property !-- Disable the second-level cache -- property name=vider_classorg.hibernate.cache.NoCacheProvider/property !-- Echo all executed SQL to stdout -- property name=show_sqltrue/property property name=format_sqltrue/p

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档