applicationContext.xml

本文详细介绍了Spring框架的配置方式,包括数据源配置、Hibernate整合、事务管理及任务调度等核心组件。通过具体示例展示了如何利用Spring进行Bean的管理、属性注入,并实现了定时任务的自动化执行。
<?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: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/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 ">

	<bean id="properties" 
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
        <property name="locations">  
            <list>  
                <value>classpath:/com/huawei/parc/searchcode.properties</value>
            </list>  
        </property>
    </bean>
    
	<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
		<property name="driver" value="com.mysql.jdbc.Driver" />
		<property name="driverUrl" value="jdbc:mysql://10.145.6.196/parctex" />
		<property name="user" value="root"></property>
		<property name="password" value="root"></property>
		<property name="alias" value="mysqldb"></property>
		<property name="simultaneousBuildThrottle" value="20"></property>
		<property name="maximumActiveTime" value="3600000"/>
     	<property name="houseKeepingTestSql" value="select current_date"/>
     	<property name="maximumConnectionCount" value="750"/>
     	<property name="minimumConnectionCount" value="10"/>
     	<property name="delegateProperties" value="utf-8"/>
	</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.MySQLDialect
				</prop>
<!--				<prop key="hibernate.show_sql">true</prop>-->
			</props>
		</property>
		<property name="mappingResources">
			<list>
				<value>com/huawei/parc/po/Arrivaldetails.hbm.xml</value>
				<value>com/huawei/parc/po/Barcoderelationship.hbm.xml</value>
				<value>com/huawei/parc/po/Boardrelationship.hbm.xml</value>
				<value>com/huawei/parc/po/Produceone.hbm.xml</value>
				<value>com/huawei/parc/po/Produceoneexp.hbm.xml</value>
				<value>com/huawei/parc/po/Produceoneinvalid.hbm.xml</value>
				<value>com/huawei/parc/po/Producethree.hbm.xml</value>
				<value>com/huawei/parc/po/Producetwo.hbm.xml</value>
				<value>com/huawei/parc/po/Codetype.hbm.xml</value>
				<value>com/huawei/parc/po/Servicedetails.hbm.xml</value>
				<value>com/huawei/parc/po/Notassociatecode.hbm.xml</value>
			</list>
		</property>
	</bean>
	
	<bean id="poiexcel" class="com.huawei.parc.util.POIExcel" />
	<bean id="linechart" class="com.huawei.parc.util.LineChart"></bean>
	<bean id="sendmail" class="com.huawei.parc.util.SendMail"></bean>
	<bean id="interceptionNeedInfo" class="com.huawei.parc.plugtool.producedata.InterceptionNeedInfo" scope="prototype">
		<property name="produceOneService" ref="produceOneService"></property>
		<property name="produceTwoService" ref="produceTwoService"></property>
		<property name="produceThreeService" ref="produceThreeService"></property>
		<property name="produceoneinvalidService" ref="produceoneinvalidService"></property>
	</bean>
	<bean id="dateutil" class="com.huawei.parc.util.DateUtil" scope="prototype"></bean>
	<bean id="failureParse" class="com.huawei.parc.util.parserrorcode.FailureParse">
		<property name="codetypeAction" ref="codetypeAction"></property>
	</bean>
	<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>

	<tx:annotation-driven transaction-manager="txManager" />

	<bean id="ht" class="org.springframework.orm.hibernate3.HibernateTemplate">
		<property name="sessionFactory" ref="sessionFactory"></property>
	</bean>
	
	<!-- dao -->
	<bean id="produceOneDao" class="com.huawei.parc.dao.ft.ProduceOneDao">
		<property name="hibernateTemplate" ref="ht"></property>
	</bean>
	<bean id="produceTwoDao" class="com.huawei.parc.dao.ft.ProduceTwoDao">
		<property name="hibernateTemplate" ref="ht"></property>
	</bean>
	<bean id="produceThreeDao" class="com.huawei.parc.dao.ft.ProduceThreeDao">
		<property name="hibernateTemplate" ref="ht"></property>
	</bean>
	<bean id="produceoneinvalidDao" class="com.huawei.parc.dao.ft.ProduceoneinvalidDao">
		<property name="hibernateTemplate" ref="ht"></property>
	</bean>
	<bean id="codetypeDao" class="com.huawei.parc.dao.ft.CodetypeDao">
		<property name="hibernateTemplate" ref="ht"></property>
	</bean>
	<bean id="dataAnalyseDao" class="com.huawei.parc.dao.analyse.DataAnalyseDao">
		<property name="hibernateTemplate" ref="ht"></property>
	</bean>
	<bean id="arrivalDetailsDAO" class="com.huawei.parc.dao.comback.ArrivalDetailsDAO">
		<property name="hibernateTemplate" ref="ht"></property>
	</bean>
	<bean id="serviceDetailsDAO" class="com.huawei.parc.dao.comback.ServiceDetailsDAO">
		<property name="hibernateTemplate" ref="ht"></property>
	</bean>
	<bean id="barcodeRelationShipDAO" class="com.huawei.parc.dao.comback.BarcodeRelationShipDAO">
		<property name="hibernateTemplate" ref="ht"></property>
	</bean>
	<bean id="boardRelationShipDAO" class="com.huawei.parc.dao.comback.BoardRelationShipDAO">
		<property name="hibernateTemplate" ref="ht"></property>
	</bean>

	<!-- service -->
	<bean id="produceOneService" class="com.huawei.parc.service.ft.ProduceOneService">
		<property name="produceOneDao" ref="produceOneDao"></property>
		<property name="dateUtil" ref="dateutil"></property>
		<property name="linechart" ref="linechart"></property>
		<property name="arrivalDetailsService" ref="arrivalDetailsService"></property>
		<property name="serviceDetailsService" ref="serviceDetailsService"></property>
	</bean>
	<bean id="produceTwoService" class="com.huawei.parc.service.ft.ProduceTwoService">
		<property name="produceTwoDao" ref="produceTwoDao"></property>
	</bean>
	<bean id="produceThreeService" class="com.huawei.parc.service.ft.ProduceThreeService">
		<property name="produceThreeDao" ref="produceThreeDao"></property>
	</bean>
	<bean id="produceoneinvalidService" class="com.huawei.parc.service.ft.ProduceoneinvalidService">
		<property name="produceoneinvalidDao" ref="produceoneinvalidDao"></property>
	</bean>
	<bean id="codetypeService" class="com.huawei.parc.service.ft.CodetypeService">
		<property name="codetypeDao" ref="codetypeDao"></property>
	</bean>
	<bean id="dataAnalyseService" class="com.huawei.parc.service.analyse.DataAnalyseService">
		<property name="dataAnalyseDao" ref="dataAnalyseDao"></property>
		<property name="failureParse" ref="failureParse"></property>
	</bean>
	<bean id="arrivalDetailsService" class="com.huawei.parc.service.comback.ArrivalDetailsService">
		<property name="arrivalDetailsDAO" ref="arrivalDetailsDAO"></property>
		<property name="barcodeRelationShipService" ref="barcodeRelationShipService"></property>
		<property name="boardRelationShipService" ref="boardRelationShipService"></property>
		<property name="produceOneService" ref="produceOneService"></property>
	</bean>
	<bean id="serviceDetailsService" class="com.huawei.parc.service.comback.ServiceDetailsService">
		<property name="barcodeRelationShipService" ref="barcodeRelationShipService"></property>
		<property name="boardRelationShipService" ref="boardRelationShipService"></property>
		<property name="produceOneService" ref="produceOneService"></property>
		<property name="serviceDetailsDAO" ref="serviceDetailsDAO"></property>
	</bean>
	<bean id="barcodeRelationShipService" class="com.huawei.parc.service.comback.BarcodeRelationShipService">
		<property name="barcodeRelationShipDAO" ref="barcodeRelationShipDAO"></property>
	</bean>
	<bean id="boardRelationShipService" class="com.huawei.parc.service.comback.BoardRelationShipService">
		<property name="boardRelationShipDAO" ref="boardRelationShipDAO"></property>
	</bean>

	<!-- action -->
	<bean id="showExcelAction" class="com.huawei.parc.action.ft.ShowExcelAction">
		<property name="excel" ref="poiexcel"></property>
		<property name="codetypeAction" ref="codetypeAction"></property>
	</bean>
	<bean id="produceOneAction" class="com.huawei.parc.action.ft.ProduceOneAction"
		scope="prototype">
		<property name="produceOneService" ref="produceOneService"></property>
		<property name="showExcelAction" ref="showExcelAction"></property>
		<property name="arrivalDetailsAction" ref="arrivalDetailsAction"></property>
		<property name="serviceDetailsService" ref="serviceDetailsService"></property>
	</bean>
	<bean id="produceTwoAction" class="com.huawei.parc.action.ft.ProduceTwoAction"
		scope="prototype">
		<property name="produceTwoService" ref="produceTwoService"></property>
		<property name="showExcelAction" ref="showExcelAction"></property>
	</bean>
	<bean id="produceThreeAction" class="com.huawei.parc.action.ft.ProduceThreeAction" scope="prototype">
		<property name="produceThreeService" ref="produceThreeService"></property>
		<property name="showExcelAction" ref="showExcelAction"></property>
	</bean>
	<bean id="codetypeAction" class="com.huawei.parc.action.ft.CodetypeAction">
		<property name="codetypeService" ref="codetypeService"></property>
	</bean>
	<bean id="sendMailAction" class="com.huawei.parc.action.ft.SendMailAction"></bean>
	<bean id="extractDataAction" class="com.huawei.parc.action.ft.ExtractDataAction" scope="prototype"></bean>
	<bean id="showChartAction" class="com.huawei.parc.action.ft.ShowChartAction" scope="prototype">
		<property name="drvCode" value="${search.code}"></property>
		<property name="produceOneAction" ref="produceOneAction"></property>
	</bean>
	<bean id="managerAction" class="com.huawei.parc.action.manage.ManagerAction" scope="prototype">
		<property name="drvCode" value="${search.code}"></property>
		<property name="extractDataAction" ref="extractDataAction"></property>
	</bean>
	<bean id="dataAnalyseAction" class="com.huawei.parc.action.analyse.DataAnalyseAction" scope="prototype">
		<property name="dataAnalyseService" ref="dataAnalyseService"></property>
		<property name="showExcelAction" ref="showExcelAction"></property>
	</bean>
	<bean id="arrivalDetailsAction" class="com.huawei.parc.action.comback.ArrivalDetailsAction" scope="prototype">
		<property name="arrivalDetailsService" ref="arrivalDetailsService"></property>
		<property name="showExcelAction" ref="showExcelAction"></property>
		<property name="produceOneService" ref="produceOneService"></property>
	</bean>
	<bean id="serviceDetailsAction" class="com.huawei.parc.action.comback.ServiceDetailsAction" scope="prototype">
		<property name="serviceDetailsService" ref="serviceDetailsService"></property>
		<property name="showExcelAction" ref="showExcelAction"></property>
		<property name="produceOneService" ref="produceOneService"></property>
	</bean>
	<bean id="barcodeRelationShipAction" class="com.huawei.parc.action.comback.BarcodeRelationShipAction" scope="prototype">
		<property name="barcodeRelationShipService" ref="barcodeRelationShipService"></property>
	</bean>
	<bean id="boardRelationShipAction" class="com.huawei.parc.action.comback.BoardRelationShipAction" scope="prototype">
		<property name="boardRelationShipService" ref="boardRelationShipService"></property>
	</bean>
	
	<!-- 自动寻找注入 -->
	<aop:aspectj-autoproxy />

	<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<ref local="estimateLogTriggerQuartz"/>
				<ref local="autoselectcodeQuartz"/>
			</list>
		</property>
	</bean>
	
	<!-- 每天自动获取生产信息bean -->
	<bean id="estimateLog" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<!-- 引用一个Bean -->
		<property name="targetObject" ref="extractDataAction"/>
		<!-- 指定目标Bean的方法 -->
		<property name="targetMethod" value="getDataAndSendMail"/>
	</bean>
	
	<!-- 每天自动获取生产信息触发器 -->
	<bean id="estimateLogTriggerQuartz" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="estimateLog"/>
		<!-- 每天晚上01:19:25执行 -->
		<property name="cronExpression" value="25 19 01 * * ?"/>
	</bean>
	
	<!-- 每月自动查询bean -->
	<bean id="autoselectcode" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<!-- 引用一个Bean -->
		<property name="targetObject" ref="extractDataAction"/>
		<!-- 指定目标Bean的方法 -->
		<property name="targetMethod" value="timingSearch"/>
	</bean>
	
	<!-- 每月自动查询触发器 -->
	<bean id="autoselectcodeQuartz" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="autoselectcode"/>
		<!-- 每月6号早上10点自动执行 -->
		<property name="cronExpression" value="0 0 10 6 * ?"/>
	</bean>
	
</beans>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值