BOS物流项目07———bos-web模块配置之applicationContext.xml

  • BOS物流项目07bos-web模块配置之applicationContextxml
    • 一dbproperties文件
    • 二applicationContextxml
    • 三配置说明
    • 四参考文章
    • 五源码下载

BOS物流项目07———bos-web模块配置之applicationContext.xml

一、db.properties文件

这个文件配置数据库连接的

jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.jdbcUrl=jdbc:mysql:///bosdb
jdbc.user=xiaoming
jdbc.password=123456

二、applicationContext.xml


<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:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context.xsd
                        http://www.springframework.org/schema/aop
                        http://www.springframework.org/schema/aop/spring-aop.xsd
                        http://www.springframework.org/schema/tx
                        http://www.springframework.org/schema/tx/spring-tx.xsd">

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

    
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driverClass}"/>
        <property name="jdbcUrl" value="${jdbc.jdbcUrl}"/>
        <property name="user" value="${jdbc.user}"/>
        <property name="password" value="${jdbc.password}"/>
    bean>

    
    <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialectprop>
                <prop key="hibernate.hbm2ddl.auto">updateprop>
                <prop key="hibernate.show_sql">trueprop>
                <prop key="hibernate.format_sql">trueprop>
            props>
        property>
        
        <property name="mappingLocations">
            <list>
                <value>classpath:com/qwm/bos/domain/*.xmlvalue>
            list>
        property>
    bean>

    
    <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    bean>

    
    <context:component-scan base-package="com.qwm.bos"/>

    
    <context:annotation-config/>

    <tx:annotation-driven/>
beans>


三、配置说明

applicationContext.xml 的配置,和我们以前说的配置是一样,主要就是映射文件的配置不同而已,以前我们使用的配置是


<property name="mappingDirectoryLocations" value="classpath:com/qwm/ssh_crm/domain">property>

现在我们使用的配置

 
  <property name="mappingLocations">
     <list>
        <value>classpath:com/qwm/bos/domain/*.xmlvalue>
      list>
   property>

四、参考文章

SSH与SSM学习之SSH整合06——Hibernate与Spring整合

SSH与SSM学习之SSH整合07——Spring整合c3p0连接池


五、源码下载

https://github.com/wimingxxx/bos-parent

你可能感兴趣的:(BOS物流项目笔记,SSH与SSM学习)