数据库连接配置笔记备用

数据库连接配置笔记备用
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
	<bean id="DataSource"
		class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName"
			value="com.mysql.jdbc.Driver" />
		<property name="url"
			value="jdbc:mysql://192.168.0.1/tta" />
		<property name="username" value="test" />
		<property name="password" value="test" />
		<property name="initialSize" value="5" />
		<property name="maxActive" value="50" />
		<property name="maxWait" value="-1" />
		<property name="maxIdle" value="5" />
		<property name="removeAbandoned" value="true" />
		<property name="removeAbandonedTimeout" value="30000" />
		<property name="logAbandoned" value="true" />
	</bean>
	
	<bean id="sessionFactory"
		class="com.hibernate.LocalSessionFactoryBean">
		<property name="dataSource">
			<ref bean="DataSource" />
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					com.hibernate.dialect.MySQL5Dialect
				</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.jdbc.fetch_size">50</prop>
				<prop key="hibernate.jdbc.batch_size">30</prop>
			</props>
		</property>
		<property name="mappingLocations">
			<list>
				<value>classpath:com/model/*.hbm.xml</value>
			</list>
		</property>
	</bean>
</beans>

你可能感兴趣的:(spring,Hibernate,bean,xml)