<?xml version="1.0" encoding="gb2312"?>
<!--  Spring配置文件的DTD定义-->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<!--  Spring配置文件的根元素是beans-->
<beans>
    <!--定义数据源,该bean的ID为dataSource-->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <!--  指定数据库驱动-->
        <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
        <!--  指定连接数据库的URL-->                  
        <property name="url"><value>jdbc:mysql://wonder:3306/j2ee</value></property>
        <!--  root为数据库的用户名-->
        <property name="username"><value>root</value></property>
        <!--  pass为数据库密码-->
        <property name="password"><value>pass</value></property>
       </bean>

<!--定义Hibernate的SessionFactory-->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <!--  依赖注入数据源,注入正是上文定义的dataSource-->
        <property name="dataSource"><ref local="dataSource"/></property>
        <!--  mappingResouces属性用来列出全部映射文件>
        <property name="mappingResources">
            <list>
                <!--以下用来列出所有的PO映射文件-->
                <value>lee/Person.hbm.xml</value>
            </list>
        </property>
        <!--定义Hibernate的SessionFactory的属性 -->
        <property name="hibernateProperties">
            <props>
                <!--  指定Hibernate的连接方言-->
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <!--  不同数据库连接,启动时选择create,update,create-drop-->
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
    </bean>

<!--  配置Person持久化类的DAO bean-->
    <bean id="personDao" class="lee.PersonDaoImpl">
        <!--  采用依赖注入来传入SessionFactory的引用-->
        <property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
</beans>

applicationContext.xml文件配置模板的更多相关文章

  1. web.xml文件配置模板

    直接贴完整代码,当然,spring的核心控制器依赖包需要通过mean提前配置 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.// ...

  2. spring +springmvc+mybatis组合applicationContext.xml文件配置

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...

  3. SSH框架整合--applicationContext.xml文件配置实例

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...

  4. dispatcher-servlet.xml文件配置模板

    完整代码如下: <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http:/ ...

  5. SSH applicationContext.xml文件配置

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  6. ssh2学习-applicationContext.xml文件配置-----<context:annotation-config/>详解

    当我们需要使用BeanPostProcessor时,直接在Spring配置文件中定义这些Bean显得比较笨拙,例如: 使用@Autowired注解,必须事先在Spring容器中声明AutowiredA ...

  7. Spring框架入门之基于xml文件配置bean详解

    关于Spring中基于xml文件配置bean的详细总结(spring 4.1.0) 一.Spring中的依赖注入方式介绍 依赖注入有三种方式 属性注入 构造方法注入 工厂方法注入(很少使用,不推荐,本 ...

  8. Spring MVC框架下在java代码中访问applicationContext.xml文件中配置的文件(可以用于读取配置文件内容)

    <bean id="propertyConfigurer" class="com.****.framework.core.SpringPropertiesUtil& ...

  9. SSH整合,applicationContext.xml中配置hibernate映射文件问题

    今天在applicationContext.xml中配置sessionFactory时遇到了各种头疼的问题,现在总结一下: 1.<property name="mappingDirec ...

随机推荐

  1. HDU1115--Lifting the Stone(求凸多边形的重心)

    Problem Description There are many secret openings in the floor which are covered by a big heavy sto ...

  2. Ubuntu为已经安装的PHP7单独编译mysqli

    编译安装PHP7后没有在ext中没有生成mysqli.so等文件,现在单独编译安装mysqli php7安装的位置:/usr/local/php7/ 我的扩展目录:/usr/local/php7/li ...

  3. 《Windows驱动开发技术详解》之驱动程序调用驱动程序——通过设备指针调用其他驱动程序

    本节介绍“手动”构造各个IRP,然后将IRP传递到相应驱动程序的派遣函数里. 获得设备指针 每个内核中的句柄都会和一个内核对象的指针联系起来.ZwCreateFile内核函数可以通过设备名打开设备句柄 ...

  4. php文件去重复,二维数组筛选

    http://www.porter.com/fr/fr/product/648162|Sneakershttp://www.porter.com/fr/fr/product/642115|Bootsh ...

  5. MyBatis和SpringMVC集成事务在Junit测试下有效但是在实际项目无效的问题

    一.问题说明 项目框架采用SSM,集成了事务回滚(方式见下),在单元测试的时候,测试事务是有效的,但是在实际项目上线的时候,却没有效果. 二.集成方式 application-mybatis.xml( ...

  6. centos 7 切换运行模式

    如设置命令行级别方法: systemctl set-default multi-user.target 设置窗口级别方法: systemctl set-default graphical.target

  7. angular跨域访问的问题

    CORS跨域资源共享 跨域资源共享(CORS )是一种网络浏览器的技术规范,它为Web服务器定义了一种方式,允许网页从不同的域访问其资源. Form responseHeaders = (Form) ...

  8. iOS 协同开发出fatal error: file 'XX-Prefix.pch' has been modified since the precompiled header was built

    http://blog.sina.com.cn/s/blog_6f8ed1b90101ake6.html 解决方法 1)http://stackoverflow.com/questions/14793 ...

  9. velocity 语法

    1,如果调用是第一条就加上类名current. #foreach($info in $aboutlist) <li><a href="$!{info.href}" ...

  10. Linux入门学习教程:虚拟机体验之KVM篇

    本文中可以学习到的命令: 1. aptitude 是apt-get 不会产生垃圾的版本 2.       dpkg -L virtualbox 显示属于该包的文件 lsmod | grep kvmfi ...