Spring配置

配置文件名:applicationContext.xml


<?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:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    
    <!-- Spring整合Hibernate -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="configLocation"
            value="classpath:hibernate.cfg.xml">
        </property>
    </bean>
    
    <bean id="userDao" class="com.troyforever.example.mvc.dao.UserImpl">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

    <!-- 分页 -->
    <bean id="pageDao" class="com.troyforever.example.mvc.dao.PageDao">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    
    <bean id="contactDao" class="com.troyforever.example.mvc.dao.ContactImpl">
        <property name="sessionFactory" ref="sessionFactory"></property>
        <property name="pageDao" ref="pageDao"></property>
    </bean>
</beans>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 转http://www.cnblogs.com/vigarbuaa/p/3616947.htmlSpring容器最...
    shenyoujian阅读 2,449评论 0 2
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,860评论 18 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,936评论 6 342
  • 在《深入理解Spring系列之一:开篇》的示例代码中使用如下方式去加载Spring的配置文件并初始化容器。 在we...
    JavaQ阅读 3,578评论 7 18
  • 在日本遇见穆清时,我正一家僻静的咖啡厅内消磨时光。手中的《月宫》翻到一半,书中奇怪的老人问主人公:“你会不会把一切...
    易烟_阅读 679评论 12 12