文章标题

spring4 + hibernate4

. 配置文件

<?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:aop="http://www.springframework.org/schema/aop"

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">  
   <context:component-scan base-package="cn.fanca.spring4"/>
   <aop:aspectj-autoproxy/>
   <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>          
    <property name="url" value="jdbc:mysql://localhost:3306/zswq?
    useUnicode=true&amp;characterEncoding=UTF-8"/>

    <property name="username" value="xxx"/>
    <property name="password" value="xxx"/>     
     <!-- 连接池启动时的初始值 -->
    <property name="initialSize" value="2"/>
    <!-- 连接池的最大值 -->
    <property name="maxTotal" value="6"/> 
    <!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 -->
    <property name="maxIdle" value="2"/>
    <!--  最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 -->
    <property name="minIdle" value="2"/>
</bean> 

<bean id="sessionFactory"  class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
     <property name="hibernateProperties">
    <props>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.hbm2ddl.auto">update</prop>
        <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
    </props>
    </property>

    <!-- 设置Spring取那个包中查找相应的实体类 -->
    <property name="packagesToScan">
    <list>
    <value>cn.fanca.zswq.vo.hr</value>
    </list>
    </property>
</bean>
<!-- services -->
<!--  
<bean id="petStore"  
class="org.springframework.samples.jpetstore.services.PetStoreServiceImpl">
    <property name="accountDao" ref="accountDao"/>
    <property name="itemDao" ref="itemDao"/>
    additional collaborators and configuration for this bean go here -->
<!--   </bean> -->  

<bean id="user" class="cn.fanca.spring4.main.User" scope="prototype" >
    <property name="age" value="200"></property>
</bean>
<!-- more bean definitions for services go here -->
</beans>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值