启动

@echo offREM Licensed to the Apache Software Foundation (ASF) under one or moreREM contributor license agreements. See the NOTICE file distributed withREM this work for additional information regarding copyright ownership.REM The ASF licenses this file to You under the Apache License, Version 2.0REM (the "License"); you may not use this file except in compliance withREM the License. You may obtain a copy of the License atREMREM http://www.apache.org/licenses/LICENSE-2.0REMREM Unless required by applicable law or agreed to in writing, softwareREM distributed under the License is distributed on an "AS IS" BASIS,REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.REM See the License for the specific language governing permissions andREM limitations under the License.setlocalcall "%~dp0zkEnv.cmd"set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMainecho oncall %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*endlocalpause

<beansxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"xmlns="http://www.springframework.org/schema/beans"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd"><!-- provider's application name, used for tracing dependency relationship --><dubbo:applicationname="demo-provider"/><!-- use multicast registry center to export service --><!--<dubbo:registry address="multicast://224.5.6.7:1234"/>--><dubbo:registryprotocol="zookeeper"address="localhost:2181"/><!-- use dubbo protocol to export service on port 20880 --><dubbo:protocolname="dubbo"port="20880"/><!-- service implementation, as same as regular local bean --><beanid="demoService"class="org.apache.dubbo.demo.provider.DemoServiceImpl"/><!-- declare the service interface to be exported --><dubbo:serviceinterface="org.apache.dubbo.demo.DemoService"ref="demoService"/></beans>

启动consumer

<beansxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"xmlns="http://www.springframework.org/schema/beans"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd"><!-- consumer's application name, used for tracing dependency relationship (not a matching criterion), don't set it same as provider --><dubbo:applicationname="demo-consumer"/><!-- use multicast registry center to discover service --><!--<dubbo:registry address="multicast://224.5.6.7:1234"/>--><dubbo:registryprotocol="zookeeper"address="localhost:2181"/><!-- generate proxy for the remote service, then demoService can be used in the same way as the local regular interface --><dubbo:referenceid="demoService"check="false"interface="org.apache.dubbo.demo.DemoService"/></beans>