applicationContext.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:mongo="http://www.springframework.org/schema/data/mongo"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.7.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>file:/usr/lib/newton/conf/zotDeviceConfigInfo.properties</value>
<!-- <value>zotDeviceConfigInfo.properties</value> -->
</property>
<property name="fileEncoding" value="utf-8" />
</bean>
<!-- 自动扫描注解 -->
<context:component-scan base-package="com.zhuyun" />
<mongo:mongo-client id="mongoClient" replica-set="${mongo.replica-set}">
<mongo:client-options
connections-per-host="1500"
threads-allowed-to-block-for-connection-multiplier="1"
connect-timeout="5000"
max-wait-time="120000"
socket-keep-alive="true"
socket-timeout="0"
write-concern="NORMAL"
read-preference="PRIMARY" />
<!-- write-concern="acknowledged" -->
</mongo:mongo-client>
<mongo:db-factory id="mongoDbFactory" dbname="zot_device_2_1" mongo-ref="mongoClient" />
<mongo:db-factory id="mongoDbFactory2" dbname="admin" mongo-ref="mongoClient" />
<bean id="mongoTypeMapper" class="org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper">
<constructor-arg name="typeKey">
<null/>
</constructor-arg>
</bean>
<bean id="mongoMappingContext" class="org.springframework.data.mongodb.core.mapping.MongoMappingContext"/>
<bean id="mongoConverter" class="org.springframework.data.mongodb.core.convert.MappingMongoConverter">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
<constructor-arg name="mappingContext" ref="mongoMappingContext"/>
<property name="typeMapper" ref="mongoTypeMapper" />
</bean>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
<constructor-arg name="mongoConverter" ref="mongoConverter"/>
</bean>
<bean id="mongoConverter2" class="org.springframework.data.mongodb.core.convert.MappingMongoConverter">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory2"/>
<constructor-arg name="mappingContext" ref="mongoMappingContext"/>
<property name="typeMapper" ref="mongoTypeMapper" />
</bean>
<bean id="mongoTemplateAdmin" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory2"/>
<constructor-arg name="mongoConverter" ref="mongoConverter2"/>
</bean>
<dubbo:application name="ZYIOT_DEVICE_2.1" />
<dubbo:registry protocol="zookeeper" address="${zookeeper.address}" />
<dubbo:consumer timeout="50000" />
<dubbo:reference id="userController" interface="com.zhuyun.user.dubbo.UserController" sent="true" check="false" async="false" />
<dubbo:reference id="bindController" interface="com.zhuyun.bind.dubbo.BindController" sent="true" check="false" async="false" />
<dubbo:reference id="triggerController" interface="com.zhuyun.trigger.dubbo.TriggerController" sent="true" check="false" async="false" />
<dubbo:reference id="timingLinkageController" interface="com.zhuyun.timing_linkage.dubbo.TimingLinkageController" sent="true" check="false" async="false" />
<dubbo:reference id="logController" interface="com.zhuyun.log.dubbo.LogController" sent="true" check="false" async="false" />
<dubbo:reference id="yotDubboService" interface="com.zhuyun.newtonproject.yot.server.dubbo.service.YotDubboService" sent="true" check="false" async="false" />
<!-- 具体的实现bean -->
<bean id="deviceController" class="com.zhuyun.device.dubbo.impl.DeviceControllerImpl" />
<bean id="deviceService" class="com.zhuyun.device.dubbo.impl.DeviceServiceImpl" />
<bean id="zotDubboService" class="com.zhuyun.newtonproject.zot.server.dubbo.service.impl.ZotDubboServiceImpl" />
<dubbo:protocol name="dubbo" host="${dubbo.host}" port="${dubbo.port}" threads="1500" queues="3000" accepts="1500"/>
<!-- 声明需要暴露的服务接口 -->
<dubbo:service interface="com.zhuyun.device.dubbo.DeviceController" ref="deviceController" />
<dubbo:service interface="com.zhuyun.device.dubbo.DeviceService" ref="deviceService" />
<dubbo:service interface="com.zhuyun.newtonproject.zot.server.dubbo.service.ZotDubboService" ref="zotDubboService" />
</beans>
下面是配置文件zotDeviceConfigInfo.properties
zookeeper.address=192.168.10.15:2181
dubbo.host=192.168.10.245
dubbo.port=9313
#mongo.replica-set=192.168.10.13\:9399,192.168.10.14\:9399,192.168.10.15\:9399
mongo.replica-set=192.168.10.15\:27017