src/beans.xml

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns="http://www.springframework.org/schema/beans" 
		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-4.2.xsd 
							http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd 
							http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
							http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd ">


				<context:annotation-config/>
					<!-- 打开自动扫描 -->
			<context:component-scan base-package="cn.itbaizhan" />
	<!-- 配置数据源和数据库连接池 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
	<property name="driverClass" value="org.gjt.mm.mysql.Driver"/>
	<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/webshopping?useUnicode=true&amp;characterEncoding=UTF-8" />
	<property name="user" value="root"/>
	<property name="password" value="root"/>
	<!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
        <property name="initialPoolSize" value="1"/>
	<!--连接池中保留的最小连接数。-->
        <property name="minPoolSize" value="1"/>	
	<!--连接池中保留的最大连接数。Default: 15 -->
        <property name="maxPoolSize" value="100"/>
	<!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
        <property name="maxIdleTime" value="60"/>	
	<!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
        <property name="acquireIncrement" value="5"/>	
	<!--每60秒检查所有连接池中的空闲连接。Default: 0 -->
        <property name="idleConnectionTestPeriod" value="60"/>
	
</bean>

	<!-- 将数据源注入到Spring的sessionFactory中 -->
<!--<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 

		<property name="dataSource" ref="dataSource"/>
		<property name="packagesToScan">
    		<list>
    		 	<value>cn.itbaizhan.po</value>
    		</list>
   		</property>
		<property name="hibernateProperties">
				<props>
					<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
					<prop key="hibernate.hbm2ddl.auto">update</prop>
					<prop key="hibernate.show_sql">true</prop>
					<prop key="format_sql">true</prop>
				</props>
		</property>

</bean>
	
	<!-- 配置spring的HibernateTemplate的事务模版 -->
	<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
		<property name="sessionFactory" ref="sessionFactory"></property>
后面还有 3 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。