<?xml version="1.0" encoding="UTF-8"?>

 <beans xmlns="http://www.springframework.org/schema/beans"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"

 xmlns:tx="http://www.springframework.org/schema/tx"

 xsi:schemaLocation="

 http://www.springframework.org/schema/beans

 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

 http://www.springframework.org/schema/context

 http://www.springframework.org/schema/context/spring-context-3.0.xsd

 http://www.springframework.org/schema/tx

  http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

 <context:property-placeholder location="classpath:jdbc.properties" />

 <context:component-scan base-package="net.roseindia" />

 <tx:annotation-driven transaction-manager="hibernateTransactionManager"

 />

 <bean id="jspViewResolver"

 class="org.springframework.web.servlet.view.InternalResourceViewResolver">

 <property name="viewClass"

 value="org.springframework.web.servlet.view.JstlView"/>

 <property name="prefix" value="/WEB-INF/view/"/>

 <property name="suffix" value=".jsp"/>

 </bean>

 <bean id="dataSource"

 class="org.springframework.jdbc.datasource.DriverManagerDataSource">

 <property name="driverClassName" value="${database.driver}" />

 <property name="url" value="${database.url}" />

 <property name="username" value="${database.user}" />

 <property name="password" value="${database.password}" />

 </bean>

 <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
</props>
</property>
</bean>
<!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="annotatedClasses"> <list> <value>net.roseindia.model.Article</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> </props> </property> </bean> -->
<bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> </beans>

hibernate.cfg.xml

 <?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration>
<session-factory>
<mapping class="net.roseindia.model.Article" />
</session-factory>
</hibernate-configuration>

结构

()-servlet.xml中剥离出的hibernate.cfg.xml的更多相关文章

  1. hibernate.properties与hibernate.cfg.xml 区别

    Hibernate的数据库连接信息是从配置文件中加载的. Hibernate的配置文件有两种形式:一种是XML格式的文件,一种是properties属性文件. 一)hibernate.cfg.xml ...

  2. 关于Could not parse configuration: /hibernate.cfg.xml的问题

    第一次在eclipse上配置hibernate,问题百出啊,比如下面的org.hibernate.HibernateException: Could not parse configuration: ...

  3. 2.Hibernate的主配置文件hibernate.cfg.xml

    1.配置 Hibernate 需要事先知道在哪里找到映射信息,这些映射信息定义了 Java 类怎样关联到数据库表.Hibernate 也需要一套相关数据库和其它相关参数的配置设置.所有这些信息通常是作 ...

  4. Spring整合Hibernate的时候使用hibernate.cfg.xml

    Spring整合Hibernate其实也就是把Hibernate的SessionFactory对象封装成:org.springframework.orm.hibernate3.LocalSession ...

  5. 给Eclipse中hibernate.cfg.xml配置文件加提示

    在hibernate框架需要的jar包中找到hibernate3.jar,并用压缩软件打开,如图: 2 选择org文件夹--打开下一级文件夹 3 点击类型,方便找到dtd文件,下拉查看dtd文件,有两 ...

  6. 将hibernate.cfg.xml文件都放到spring中时报错

    报错如下所示: 私以为是配置文件出现问题了. <?xml version="1.0" encoding="UTF-8"?> <beans xm ...

  7. java:Hibernate框架1(环境搭建,Hibernate.cfg.xml中属性含义,Hibernate常用API对象,HibernteUitl,对象生命周期图,数据对象的三种状态,增删查改)

    1.环境搭建: 三个准备+7个步骤 准备1:新建项目并添加hibernate依赖的jar文件  准备2:在classpath下(src目录下)新建hibernate的配置文件:hibernate.cf ...

  8. 【Hibernate学习笔记-4】在hibernate.cfg.xml中配置C3P0数据源

    jar包 hibernate.cfg.xml <?xml version="1.0" encoding="GBK"?> <!DOCTYPE h ...

  9. hibernate.cfg.xml 配置(摘录)

    配置文件中映射元素详解 对象关系的映射是用一个XML文档来说明的.映射文档可以使用工具来生成,如XDoclet,Middlegen和AndroMDA等.下面从一个映射的例子开始讲解映射元素,映射文件的 ...

随机推荐

  1. HTML入门与基础 —— 标签《一》

    一.标签概述 1.HTML(英文Hyper Text Markup Language的缩写)中文译为“超文本标签语言”,主要是通过HTML标签对网页中的文本.图片.声音等内容进行描述. 2.标签分为嵌 ...

  2. zabbix 安装小结

    其实很简单的东西,结果折腾了好久.首先去官网 下个source,然后按照文档来 https://www.zabbix.com/documentation/3.2/manual/installation ...

  3. RHEL 6.5---SVN服务实现过程

    主机名 IP地址  master 192.168.30.130 slave 192.168.30.131 安装 [root@master ~]# yum install -y subversion h ...

  4. AJPFX浅谈Java 性能优化之字符串过滤实战

    ★一个简单的需求 首先描述一下需求:给定一个 String 对象,过滤掉除了数字(字符'0'到'9')以外的其它字符.要求时间开销尽可能小.过滤函数的原型如下: String filter(Strin ...

  5. 【转】Iconfont

    Iconfont Iconfont 是指用字体文件取代图片文件,来展示图标.特殊字体等元素的一种方法.很多网站都会用它,比如手淘.新浪微博等. 在使用它之前,先来了解一下它的优缺点: 优点:(1)文件 ...

  6. CF983A Finite or not?

    思路: 如果p,q不互质,先把q除以p,q的最大公约数.接下来只要b中包含了所有q的质因子就可以了.可以在gcd(q, b) 不等于1的时候不断地用q除以gcd(q, b).最后如果q等于1,说明Fi ...

  7. htm 中 <b>和<strong>的区别

    显示上两者没有任何区别,都是粗体<b>:为了加粗而加粗,推荐使用 css font-weight 属性来创建粗体文字.<strong>:为了强调而加粗,表示十分重要.在网页中使 ...

  8. C# 移动控件

    最近要做车牌识别的,不同地区收费标准不一,所以想做个可以移动控件来给客户选择停车场收费条件的.   首先因为要自动排序控件选FlowLayoutPanel做容器,加若干Panel和FlowLayout ...

  9. 如何处理Docker的错误消息request canceled:Docker代理问题

    在本地安装Kubernetes时,遇到错误消息: request canceled while waiting for connection(Client.Timeout exceeded while ...

  10. instance of type of object.prototype.tostring 区别

    typeof typeof 是一个操作符,其右侧跟一个一元表达式,并返回这个表达式的数据类型.   返回的结果用该类型的字符串(全小写字母)形式表示,包括以下 6 种:   number.boolea ...