<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/mmpic
Unicode=true&characterEncoding=utf8">
</property>
<property name="username" value="root">
</property>
<property name="password" value="123456">
</property>
<property name="initialSize" value="2">
</property>
<property name="maxActive" value="10">
</property>
<property name="maxIdle" value="2">
</property>
<property name="minIdle" value="1">
</property>
<property name="maxWait" value="30000">
</property>
</bean>
<!-- 配置会话工厂() -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/> <!-- 设置数据源 -->
<!-- 接管了hibernate对象映射文件 -->
<property name="mappingResources">
<list>
<value>com/tarena/pojo/Mm.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
</bean>
<!-- 配置dao对象 -->
<bean id="mmDao" class="com.tarena.imp.HibernateMmDAO">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 配置Action -->
<bean id="listAction" class="com.tarena.action.ListAction">
<property name="mmDao">
<ref bean="mmDao" />
</property>
</bean>
<!-- 配置事务管理器-->
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
</beans>
<!-- 注解-->
<context:annotation-config />
<aop:aspectj-autoproxy />
<!-- 支持aop注解方式 -->
<context:component-scan base-package="xxx" />
<!-- 把struts2交给spring管理 没这句ssh无法集成 -->
<constant name="struts.objectFactory" value="spring" />
<!-- 解决乱码 -->
<constant name="struts.i18n.encoding" value="utf-8"></constant>