<?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: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-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd" default-lazy-init="true"> <!-- 获取数据库连接配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>WEB-INF/database.properties</value> </list> </property> </bean> <!-- 读配置文件通过数据库连接池连接数据库 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}"> </property> <property name="url" value="${jdbc.url}"></property> <property name="username" value="${jdbc.username}"></property> <property name="password" value="${jdbc.password}"></property> </bean> <!-- 配置数据库事务管理 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!-- 配置事务特性 --> <tx:advice id="txAdvice"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/> <tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> <!-- 配置哪些方法需要配置事务管理 --> <aop:config> <aop:pointcut id="allServiceMethod" expression="excution(*com.arvato.serviceimpl.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethod"/> </aop:config> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation" value="/WEB-INF/classes/sqlMapConfig.xml"> </property> <property name="dataSource" ref="dataSource"></property> </bean> <!-- bean中的class为实现接口的类;property的name为类中引用的属性名称;ref为spring注册的名称--> <bean id="marketProDao" class="com.arvato.daoimpl.MarketProDAOImpl" scope="prototype"> <property name="sqlMapClient" ref="sqlMapClient"></property> </bean> <bean id="budgetDao" class="com.arvato.daoimpl.BudgetDAOImpl" scope="prototype"> <property name="sqlMapClient" ref="sqlMapClient"></property> </bean> <bean id="sqlObjDao" class="com.arvato.daoimpl.SqlObjDAOImpl" scope="prototype"> <property name="sqlMapClient" ref="sqlMapClient"></property> </bean> <bean id="marketProService" class="com.arvato.serviceimpl.MarketProService" scope="prototype"> <property name="marketProDao" ref="marketProDao"></property> </bean> <bean id="budgetService" class="com.arvato.serviceimpl.BudgetService" scope="prototype"> <property name="budgetDao" ref="budgetDao"></property> </bean> <bean id="sqlObjService" class="com.arvato.serviceimpl.SqlObjService"> <property name="sqlObjDao" ref="sqlObjDao"></property> </bean> <bean id="MarketProAction" class="com.arvato.struts.MarketProAction" scope="prototype"> <property name="mktProService" ref="marketProService"></property> </bean> <bean id="BudgetAction" class="com.arvato.struts.BudgetAction" scope="prototype"> <property name="budgetService" ref="budgetService"></property> </bean> <bean id="BaseMarketAction" class="com.arvato.struts.BaseMarketAction" scope="prototype"> <property name="marketProService" ref="marketProService"></property> </bean> <bean id="DealSqlAction" class="com.arvato.struts.DealSqlAction" scope="prototype"> <property name="sqlObjService" ref="sqlObjService"></property> </bean> </beans>