4、看看spring的配置,ApplicationContext.xml配置文件中的配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://.springframework.org/schema/beans"
xmlns:xsi="http://.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://.springframework.org/schema/tx"
xmlns:context="http://.springframework.org/schema/context"
xmlns:aop="http://.springframework.org/schema/aop"
xmlns:task="http://.springframework.org/schema/task"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://.springframework.org/schema/beans
http://.springframework.org/schema/beans/spring-beans-3.2.xsd
http://.springframework.org/schema/context
http://.springframework.org/schema/context/spring-context-3.2.xsd
http://.springframework.org/schema/aop
http://.springframework.org/schema/aop/spring-aop.xsd
http://.springframework.org/schema/task
http://.springframework.org/schema/task/spring-task-3.2.xsd
http://.springframework.org/schema/tx
http://.springframework.org/schema/tx/spring-tx-3.2.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
">
<!-- 加载配置JDBC文件 -->
<context:property-placeholder location="classpath:datasource.properties" />
<!-- 数据源 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="driverClassName">
<value>${druid.driverClassName}</value>
</property>
<property name="url">
<value>${druid.url}</value>
</property>
<property name="username">
<value>${druid.username}</value>
</property>
<property name="password">
<value>${druid.password}</value>
</property>
<property name="filters" value="stat" />
<property name="initialSize">
<value>${druid.initialSize}</value>
</property>
<property name="minIdle">
<value>${druid.minIdle}</value>
</property>
<property name="maxActive">
<value>${druid.maxActive}</value>
</property>
<property name="maxWait">
<value>${druid.maxWait}</value>
</property>
<property name="timeBetweenEvictionRunsMillis">
<value>${druid.timeBetweenEvictionRunsMillis}</value>
</property>
<property name="minEvictableIdleTimeMillis">
<value>${druid.minEvictableIdleTimeMillis}</value>
</property>
<property name="testWhileIdle">
<value>${druid.testWhileIdle}</value>
</property>
<property name="testOnBorrow">
<value>${druid.testOnBorrow}</value>
</property>
<property name="testOnReturn">
<value>${druid.testOnReturn}</value>
</property>
<property name="poolPreparedStatements">
<value>${druid.poolPreparedStatements}</value>
</property>
<property name="maxPoolPreparedStatementPerConnectionSize">
<value>${druid.maxPoolPreparedStatementPerConnectionSize}</value>
</property>
</bean>
<context:component-scan base-package="com.test.dubboser3.service ,com.test.dubboser3.dao" />
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="" />
<property name="mapperLocations" value="classpath:mapper/*.xml" />
</bean>
<!--其实这里类的实例就是mybatis中SQLSession -->
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0">
<ref bean="sqlSessionFactory" />
</constructor-arg>
</bean>
<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- dubbo 服务配置 -->
<!-- 提供方应用信息,用于计算依赖关系,这个和client没必要一致 -->
<dubbo:application name="hello-world-app-my" />
<!-- 使用multicast广播注册中心暴露服务地址 -->
<!-- <dubbo:registry address="multicast://192.168.0.101:2181" /> -->
<!-- 使用zookeeper广播注册中心暴露服务地址 -->
<dubbo:registry protocol="zookeeper" address="192.168.0.103:2181"/>
<!--和上面的配置是一样的效果 -->
<!-- <dubbo:registry address="zookeeper://192.168.0.101:2181" /> -->
<!-- 本机 伪集群 测试 -->
<!-- <dubbo:registry protocol="zookeeper" address="192.168.0.27:2181,192.168.0.27:2182,192.168.0.27:2183" /> -->
<!-- 用dubbo协议在20880端口暴露服务 -->
<dubbo:protocol name="dubbo" port="20880" />
<!-- 声明需要暴露的服务接口 -->
<dubbo:service intece="com.test.dubboser3.service.UserService"
ref="demoService" />
<!-- 和本地bean一样实现服务 -->
<bean id="demoService" class="com.test.dubboser3.service.UserServiceImp"/>
</beans>
我们看到了这个配置文件相比平时的springmvcspringmybatis 项目的配置文件就多了个dubbo的这部分配置,所以从这里看出dubbo zookeeper的使用还是挺方便的……
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-44295-3.html
疯了吧
人均GDP和收入看起来你好富啊
其实也就等同于今后任何国家到美国去巡航