---
title: "Spring的基本配置"
author: "ytzhsh"
date: "2006-04-28T16:02:56Z"
tags: []
slug: "spring"
draft: false
lastmod: "2006-04-28T16:02:56Z"
id: 23919
url: "https://ytzhsh.iteye.com/blog/23919"
---

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"&gt;
&lt;beans default-autowire="byName"&gt;
	&lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt;
		&lt;property name="driverClassName"&gt;
			&lt;value&gt;com.mysql.jdbc.Driver&lt;/value&gt;
		&lt;/property&gt;
		&lt;property name="url"&gt;&lt;value&gt;jdbc:mysql://hunan/netschool?useUnicode=true&amp;characterEncoding=gbk&lt;/value&gt;
		&lt;/property&gt;&lt;property name="username"&gt;&lt;value&gt;netschool&lt;/value&gt;&lt;/property&gt;
		&lt;property name="password"&gt;&lt;value&gt;123456&lt;/value&gt;&lt;/property&gt;
	&lt;/bean&gt;
	&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
		&lt;property name="mappingResources"&gt;
			&lt;list&gt;
				&lt;value&gt;com/aurora/netschool/entity/Administrator.hbm.xml&lt;/value&gt;
				&lt;value&gt;com/aurora/netschool/entity/Article.hbm.xml&lt;/value&gt;
				&lt;value&gt;com/aurora/netschool/entity/ClassCategory.hbm.xml&lt;/value&gt;
				&lt;value&gt;com/aurora/netschool/entity/Category.hbm.xml&lt;/value&gt;
				&lt;value&gt;com/aurora/netschool/entity/CustomLable.hbm.xml&lt;/value&gt;
				&lt;value&gt;com/aurora/netschool/entity/KeyWord.hbm.xml&lt;/value&gt;
				&lt;value&gt;com/aurora/netschool/entity/Template.hbm.xml&lt;/value&gt;
				&lt;value&gt;com/aurora/netschool/entity/Popedom.hbm.xml&lt;/value&gt;
			&lt;/list&gt;
		&lt;/property&gt;
		&lt;property name="hibernateProperties"&gt;
			&lt;props&gt;
				&lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
				&lt;prop key="hibernate.query.substitutions"&gt;true=1 false=0&lt;/prop&gt;
				&lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
				&lt;prop key="hibernate.use_outer_join"&gt;true&lt;/prop&gt;
			&lt;/props&gt;
		&lt;/property&gt;
		&lt;property name="dataSource"&gt;
			&lt;ref bean="dataSource" /&gt;
		&lt;/property&gt;
	&lt;/bean&gt;


	&lt;bean name="valueListFactory" class="com.aurora.util.valuelist.ValueListFactory"&gt;
		&lt;property name="constantsHolder"&gt;
			&lt;value&gt;com.aurora.netschool.Constants&lt;/value&gt;
		&lt;/property&gt;
	&lt;/bean&gt;

	&lt;bean name="configuration" class="com.aurora.Configuration"&gt;
		&lt;property name="configureMap"&gt;
			&lt;props&gt;
				&lt;prop key="autoAudit"&gt;true&lt;/prop&gt;
				&lt;prop key="graduateDate"&gt;07-08&lt;/prop&gt;
			&lt;/props&gt;
		&lt;/property&gt;
		&lt;property name="directoryMap"&gt;
			&lt;props&gt;
				&lt;prop key="tempDir"&gt;/tmp&lt;/prop&gt;
				&lt;prop key="uploadDir"&gt;/upload&lt;/prop&gt;
			&lt;/props&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
	&lt;bean id="articleDao" class="com.aurora.netschool.dao.impl.ArticleDaoImpl" /&gt;
	&lt;bean id="administratorDao" class="com.aurora.netschool.dao.impl.AdministratorDaoImpl" /&gt;
	&lt;bean id="categoryDao" class="com.aurora.netschool.dao.impl.CategoryDaoImpl" /&gt;
	&lt;bean id="keyWordDao" class="com.aurora.netschool.dao.impl.KeyWordDaoImpl" /&gt;
	&lt;bean id="templateDao" class="com.aurora.netschool.dao.impl.TemplateDaoImpl" /&gt;
	&lt;bean id="popedomDao" class ="com.aurora.netschool.dao.impl.PopedomDaoImpl"/&gt;
	&lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
			&lt;property name="sessionFactory"&gt;
			&lt;ref local="sessionFactory" /&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
	&lt;bean id="baseTxProxy" abstract="true" lazy-init="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"&gt;
		&lt;property name="transactionAttributes"&gt;
			&lt;props&gt;
				&lt;prop key="*"&gt;PROPAGATION_REQUIRED&lt;/prop&gt;
			&lt;/props&gt;
		&lt;/property&gt;
		&lt;property name="proxyTargetClass"&gt;
			&lt;value&gt;true&lt;/value&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
	&lt;bean id="articleService" parent="baseTxProxy"&gt;
		&lt;property name="target"&gt;
			&lt;bean class="com.aurora.netschool.service.impl.ArticleServiceImpl" /&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
	&lt;bean id="administratorService" parent="baseTxProxy"&gt;
		&lt;property name="target"&gt;
			&lt;bean class="com.aurora.netschool.service.impl.AdministratorServiceImpl" /&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
		&lt;bean id="popedomService" parent="baseTxProxy"&gt;
		&lt;property name="target"&gt;
			&lt;bean class="com.aurora.netschool.service.impl.PopedomServiceImpl" /&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
	&lt;bean id="categoryService" parent="baseTxProxy"&gt;
		&lt;property name="target"&gt;
			&lt;bean class="com.aurora.netschool.service.impl.CategoryServiceImpl" /&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
	&lt;bean id="keyWordService" parent="baseTxProxy"&gt;
		&lt;property name="target"&gt;
			&lt;bean class="com.aurora.netschool.service.impl.KeyWordServiceImpl" /&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
	&lt;bean id="templateService" parent="baseTxProxy"&gt;
		&lt;property name="target"&gt;
			&lt;bean class="com.aurora.netschool.service.impl.TemplateServiceImpl" /&gt;
		&lt;/property&gt;
	&lt;/bean&gt;
&lt;/beans&gt;