关闭

Spring的配置文件applicationContext.xml

166人阅读 评论(0) 收藏 举报
 

HTML Tags and JavaScript tutorial



Spring的配置文件applicationContext.xml





<bean id="placeholderConfig"
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="location">
  
   <!-- <value>/init.properties</value>-->
   <value>/jdbc.properties</value>
  </property>
 </bean>
 
 <!-- Choose the dialect that matches your "dataSource" definition -->
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName">
   <value>${datasource.driverClassName}</value>
  </property>
  <property name="url">
   <value>${datasource.url}</value>
  </property>
  <property name="username">
   <value>${datasource.username}</value>
  </property>
  <property name="password">
   <value>${datasource.password}</value>
  </property>
  <property name="maxActive">
   <value>${datasource.maxActive}</value>
  </property>
  <property name="maxIdle">
   <value>${datasource.maxIdle}</value>
  </property>
  <property name="maxWait">
   <value>${datasource.maxWait}</value>
  </property>
  <property name="defaultAutoCommit">
   <value>${datasource.defaultAutoCommit}</value>
  </property>
 </bean>
 <bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
  <property name="dataSource">
   <ref local="dataSource" />
  </property>
  <property name="mappingResources">
<list>
 <value>com/laoer/bbscs/bean/Online.hbm.xml</value>
 
  
   </list>
  </property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
    <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
    <prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
    <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
   </props>
  </property>
 </bean>
 
在DAO里加入:
<property name="sessionFactory">
   <ref local="mySessionFactory" />
  </property>
在Service里加入Dao
<property name="xxxDao">
   <ref local="xxxDao" />
  </property>


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:150606次
    • 积分:4030
    • 等级:
    • 排名:第7705名
    • 原创:242篇
    • 转载:0篇
    • 译文:0篇
    • 评论:16条
    文章存档
    最新评论