配置applicationcontext.xml文件

实际上,配置applicationcontext要把其中的东西理解透彻。要注意的地方也有很多。你比如说不同的数据库连接配置不一样。show_sql语句也与hibernate的配置不一样。

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
		<property name="url" value="jdbc:mysql://localhost:3306/xscj" />
		<property name="username" value="root" />
		<property name="password" value="123456" />
	</bean>
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.MySQLInnoDBDialect
				</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.format_sql">true</prop>
			</props>
		</property>
		<property name="mappingResources">
			<list>
				<value>org/model/Dlb.hbm.xml</value>
				<value>org/model/Xsb.hbm.xml</value>
				<value>org/model/Kcb.hbm.xml</value>
				<value>org/model/Zyb.hbm.xml</value>
				<value>org/model/Cjb.hbm.xml</value>
			</list>
		</property>
	</bean>
	<bean id="dlDao" class="dao.imp.DlDaoImp">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="xsDao" class="dao.imp.XsDaoImp">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="kcDao" class="dao.imp.KcDaoImp">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="zyDao" class="dao.imp.ZyDaoImp">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="cjDao" class="dao.imp.CjDaoImp">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="dlService" class="service.imp.DlServiceManage">
		<property name="dlDao">
			<ref bean="dlDao" />
		</property>
	</bean>
	<bean id="xsService" class="service.imp.XsServiceManage">
		<property name="xsDao">
			<ref bean="xsDao" />
		</property>
		<property name="cjDao">
			<ref bean="cjDao" />
		</property>
	</bean>
	<bean id="zyService" class="service.imp.ZyServiceManage">
		<property name="zyDao">
			<ref bean="zyDao" />
		</property>
	</bean>
	<bean id="kcService" class="service.imp.KcServiceManage">
		<property name="kcDao">
			<ref bean="kcDao" />
		</property>
	</bean>
	<bean id="cjService" class="service.imp.CjServiceManage">
		<property name="cjDao">
			<ref bean="cjDao" />
		</property>
	</bean>
	<bean id="dlAction" class="org.action.DlAction">
	<property name="dlservice">
	<ref bean="dlService"/>
	</property>
	</bean>
	<bean id="xsAction" class="org.action.XsAction">
	<property name="xsService">
	<ref bean="xsService"/>
	</property>
	<!-- <property name="zyService">
	<ref bean="zyService"/>
	</property> -->
	</bean>
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
	<property name="sessionFactory">
	<ref local="sessionFactory"/>
	</property>
	</bean>
	<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
	<property name="transactionManager" ref="transactionManager"/>
	<property name="transactionAttributes">
	<props>
	<prop key="delete*">PROPAGATION_REQUIRED</prop>
	<prop key="*">PROPAGATION_REQUIRED</prop>
	</props>
	</property>
	</bean>
	<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
	<property name="beanNames">
	<list>
	<value>dlService</value>
	<value>kcService</value>
	<value>cjService</value>
	<value>zyService</value>
	<value>xsService</value>
	</list>
	</property>
	<property name="interceptorNames">
	<list>
	<value>transactionInterceptor</value>
	</list>
	</property>
	</bean>
</beans>
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值