以下是详解Spring的applicationContext.xml文件代码:
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:appmaster.properties</value>
</list>
</property>
</bean>
<!--数据库配置-->
<bean id="mongo" class="com.mongodb.Mongo" scope="singleton" lazy-init="false">
<constructor-arg index="0" type="java.lang.String" value="${mongodb.host}"/>
<constructor-arg index="1" type="int" value="${mongodb.port}"/>
</bean>
<bean id="morphiaDataStore" class="com.babeeta.butterfly.application.management.dao.MorphiaDataStore" scope="singleton" lazy-init="false">
<property name="mongo" ref="mongo"/>
<property name="dbName" value="${mongodb.dbName}" />
<property name="mappingPackage" value="com.babeeta.butterfly.application.management.entity"/>
</bean>
<bean id="messageDataStore" class="com.babeeta.butterfly.application.management.dao.MorphiaDataStore" scope="singleton" lazy-init="false">
<property name="mongo" ref="mongo"/>
<property name="dbName" value="${messageMongodb.dbName}" />
<property name="mappingPackage" value="com.babeeta.butterfly.application.management.entity"/>
</bean>
<bean id="unRegistMobileDao" class="com.babeeta.butterfly.application.management.dao.impl.UnRegistMobileDaoImpl">
< constructor-arg ref="morphiaDataStore"></constructor-arg>
</bean>
<bean id="unRegistMobileService" class="com.babeeta.butterfly.application.management.service.impl.UnRegistMobileServiceImpl">
<property name="unRegistMobileDao" ref="unRegistMobileDao"></property>
</bean>
<!-- licence管理 -->
<bean id="licenceServiceImpl" class="com.babeeta.butterfly.application.management.service.impl.LicenceServiceImpl">
<property name="licenceDaoImpl" ref="licenceDaoImpl"></property>
<property name="appCountHost" value="${appCountHost}"></property>
</bean>
<bean id="userServiceImpl" class="com.babeeta.butterfly.application.management.service.impl.UserServiceImpl">
<property name="userDaoImpl" ref="userDaoImpl"></property>
</bean>
<!-- mail -->
<bean id="sendMailServiceImpl" class="com.babeeta.butterfly.application.management.service.impl.SendMailServiceImpl" scope="singleton" >
<property name="mailSender">
<bean class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.babeeta.com"> </property>
<property name="username" value="${mailUserName}"></property>
<property name="password" value="${mailPassword}"></property>
</bean>
</property>
<property name="velocityEngine">
<bean class="org.springframework.ui.velocity.VelocityEngineFactoryBean" >
<property name="velocityProperties">
<props>
<prop key="resource.loader">class</prop>
<prop key="class.resource.loader.class">
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
</prop>
<prop key="input.encoding">utf-8</prop>
<prop key="output.encoding">utf-8</prop>
</props>
</property>
</bean>
</property>
<property name="from" value="${mailFrom}" > </property>
<property name="host" value="${host}" > </property>
<property name="resetPwdUrl" value="${resetPwdUrl}" > </property>
</bean>
<!-- action实例 -->
<bean id="frontAction" class="com.babeeta.butterfly.application.management.action.FrontAction">
<property name="appServiceImpl" ref="appServiceImpl"></property>
<property name="messageServiceImpl" ref="messageServiceImpl"></property>
<property name="frontServiceImpl" ref="frontServiceImpl"></property>
<property name="licenceServiceImpl" ref="licenceServiceImpl"></property>
<property name="frontServiceImpl_2" ref="frontServiceImpl_2"/>
<property name="unRegistMobileService" ref="unRegistMobileService"></property>
</bean>
</beans>