applicationContent.xml 内容样例如下:
<?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:p="http://www.springframework.org/schema/p" 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-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="com.mysql.jdbc.Driver"/> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/shopping?useUnicode=true&characterEncoding=UTF-8"/> <property name="user" value="chinese"/> <property name="password" value="a123"/> <property name="maxPoolSize" value="10"/> <property name="minPoolSize" value="1"/> <property name="initialPoolSize" value="2"/> <property name="autoCommitOnClose" value="false"/> <property name="maxIdleTime" value="60"/> <property name="acquireIncrement" value="5"/> <property name="idleConnectionTestPeriod" value="60"/> </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.MySQL5Dialect </prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> <prop key="hibernate.use_sql_comments">false</prop> <!-- 自动生成数据库表 <prop key="hibernate.hbm2ddl.auto">update</prop> --> </props> </property> <property name="mappingResources"> <list> <value>com/shopping/pojo/Resource_goods.hbm.xml</value> <value>com/shopping/pojo/Good_user.hbm.xml</value> <value>com/shopping/pojo/Goods_order.hbm.xml</value> <value>com/shopping/pojo/Datiel_order.hbm.xml</value> <value>com/shopping/pojo/Good_car.hbm.xml</value> <value>com/shopping/pojo/Goods_comment.hbm.xml</value> </list> </property> </bean> <bean id="GoodsUserDAO" class="com.shopping.dao.GoodUserDAO" scope="singleton"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="GoodUserBIZ" class="com.shopping.biz.GoodUserBIZ" scope="prototype"> <property name="goodUserDao" ref="GoodsUserDAO"/> </bean> <bean id="checkLoginBean" class="com.shopping.action.LoginAction" scope="prototype"> <property name="goodUserBiz" ref="GoodUserBIZ"/> </bean> <bean id="GoodsDAO" class="com.shopping.dao.GoodsDAO" scope="singleton"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="GoodsBIZ" class="com.shopping.biz.GoodsBIZ" scope="prototype"> <property name="goodsDAO" ref="GoodsDAO"/> </bean> <bean id="showGoodsBean" class="com.shopping.action.GoodsAction" scope="prototype"> <property name="goodsBIZ" ref="GoodsBIZ"/> </bean> <bean id="CarDAO" class="com.shopping.dao.CarDAO" scope="singleton"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="CarBIZ" class="com.shopping.biz.CarBIZ" scope="prototype"> <property name="carDao" ref="CarDAO"/> <property name="goodsDao" ref="GoodsDAO"/> <property name="userDao" ref="GoodsUserDAO"/> </bean> <bean id="CarBean" class="com.shopping.action.CarAction" scope="prototype"> <property name="carBiz" ref="CarBIZ"/> </bean> <bean id="orderDAOBean" class="com.shopping.dao.OrderDAO" scope="prototype"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="orderBIZBean" class="com.shopping.biz.OrderBIZ" scope="prototype"> <property name="orderDao" ref="orderDAOBean"/> <property name="userDao" ref="GoodsUserDAO"/> <property name="carDao" ref="CarDAO"/> <property name="goodsDao" ref="GoodsDAO"/> </bean> <bean id="orderActionBean" class="com.shopping.action.OrderAction" scope="prototype"> <property name="orderBiz" ref="orderBIZBean"/> </bean> <bean id="CommentDaoBean" class="com.shopping.dao.CommentDAO" scope="singleton"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="CommentBizBean" class="com.shopping.biz.CommentBIZ" scope="prototype"> <property name="commentDao" ref="CommentDaoBean"/> <property name="goodsDao" ref="GoodsDAO"/> </bean> <bean id="CommentActionBean" class="com.shopping.action.CommentAction" scope="prototype"> <property name="commBiz" ref="CommentBizBean"/> </bean> <!-- --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <!-- 使用基于注解方式配置事务 <tx:annotation-driven transaction-manager="transactionManager"/> --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED"/> <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="*" read-only="true"/> </tx:attributes> </tx:advice> <!-- --> <aop:config> <aop:pointcut id="allManagerMethod" expression="execution(* com.shopping.action.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/> </aop:config> </beans>
供在其他的项目中参考。