1. web.xml中的配置加spring的监听器:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
2. struts-config.xml中插件配置:
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" />
</plug-in>
3. applicationcontext.xml中的配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 配置连接池 -->
<!--sqlserver2005-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="jdbcUrl" value="jdbc:sqlserver://localhost:1433;databaseName=softredb" />
<property name="user" value="softwareuser" />
<property name="password" value="122333" />
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="maxIdleTime" value="1800" />
<property name="maxStatements" value="50" />
</bean>
<!-- mysql -->
<!--
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/txdkhsdb" />
<property name="user" value="root" />
<property name="password" value="" />
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="maxIdleTime" value="1800" />
<property name="maxStatements" value="50" />
</bean>
-->
<!-- 配置jdbcTemplate -->
<bean id="Template" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<!-- 配置SessionFactory -->
<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.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>
com/software/hibernate/entity/TAddressConnection.hbm.xml
</value>
</list>
</property>
</bean>
<!-- 配置DAO -->
<bean id="TAddressConnectionDAO" class="com.software.dao.TAddressConnectionDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
<property name="template">
<ref bean="Template" />
</property>
</bean>
<!-- 配置Business 业务逻辑处理Bean-->
<bean id="Actions" class="com.software.business.Actions">
<property name="tactionDAO">
<ref bean="TActionDAO" />
</property>
<property name="template">
<ref bean="Template" />
</property>
</bean>
<!-- action -->
<bean name="/shujutongji" class="com.software.action.find.FindSjtjAction" singleton="false" lazy-init="default" autowire="default" dependency-check="default">
<property name="corporationSamenessInfo">
<ref bean="CorporationSamenessInfo" />
</property>
<property name="softwarecallingunion">
<ref bean="SoftwareCallingUnion" />
</property>
<property name="change">
<ref bean="Change" />
</property>
</bean>