一步步完成Maven+Spring+Dubbo+Zookeeper的整合示例

本文给出一个整合Maven+Spring+Dubbo+Zookeeper的示例,并且一步步给出完成步骤,并对其中可能遇到的问题进行解决~

Maven模块化

创建一个名为dubbo-demo的Maven工程,该工程包含三个模块

  • dubbo-demo-interface   (定义对外开放接口)
  • dubbo-demo-provider   (接口实现)
  • dubbo-demo-consumer (接口调用)

dubbo-demo工程中的pom.xml文件如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.xxx.dubbo.demo</groupId>
  <artifactId>dubbo-demo</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <modules>
  	<module>dubbo-demo-provider</module>
  	<module>dubbo-demo-consumer</module>
  	<module>dubbo-demo-interface</module>
  </modules>
</project>

关于dubbo-demo Maven工程的模块化构建,请参考博文【使用Maven构建模块化工程

接下来,我们就一步一步来完成interface、provider以及consumer模块的内容~

模块interface

定义接口

创建一个接口(GreetingService),包含一个hello接口,如:

package com.xxx.dubbo.demo.service;

/**
 * @author wangmengjun
 *
 */
public interface GreetingService {

	String hello(String name);
}

简单的接口就定义好了~

有了接口,就可以在Provider中完成接口的实现,并暴露接口服务为Dubbo服务给其它模块使用(如consumer)~

模块Provider

添加依赖包

  • 添加interface依赖包
		<dependency>
			<groupId>com.xxx.dubbo.demo</groupId>
			<artifactId>dubbo-demo-interface</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
  • 添加spring依赖包
<!--引入Spring依赖包 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
  • 添加dubbo依赖包
        <!-- Dubbo相关 -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>dubbo</artifactId>
			<version>2.5.4-snapshot</version>
			<exclusions>
				<exclusion>
					<groupId>org.springframework</groupId>
					<artifactId>spring</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.javassist</groupId>
			<artifactId>javassist</artifactId>
			<version>3.18.1-GA</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/io.netty/netty -->
		<dependency>
			<groupId>io.netty</groupId>
			<artifactId>netty</artifactId>
			<version>3.10.6.Final</version>
		</dependency>
  • 添加zk-client依赖包
		<!-- ZK-client -->
		<dependency>
			<groupId>com.github.sgroschupf</groupId>
			<artifactId>zkclient</artifactId>
			<version>0.1</version>
		</dependency>

dubbo-demo-provider模块详细的pom.xml文件如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>com.xxx.dubbo.demo</groupId>
		<artifactId>dubbo-demo</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<artifactId>dubbo-demo-provider</artifactId>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<spring.framework.version>4.3.6.RELEASE</spring.framework.version>
	</properties>

	<dependencies>

		<dependency>
			<groupId>com.xxx.dubbo.demo</groupId>
			<artifactId>dubbo-demo-interface</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>

		<!--引入Spring依赖包 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>

		<!-- Dubbo -->
		<dependency>
			<groupId>com.alibaba</groupId><artifactId>dubbo</artifactId><version>2.5.4-snapshot</version><exclusions><exclusion><groupId>org.springframework</groupId><artifactId>spring</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.javassist</groupId><artifactId>javassist</artifactId><version>3.18.1-GA</version></dependency><!-- https://mvnrepository.com/artifact/io.netty/netty --><dependency><groupId>io.netty</groupId><artifactId>netty</artifactId><version>3.10.6.Final</version></dependency><!-- ZK-client --><dependency><groupId>com.github.sgroschupf</groupId><artifactId>zkclient</artifactId><version>0.1</version></dependency></dependencies></project>

实现接口

编写GreetingService的实现类GreetingServiceImpl, 并实现hello方法~

package com.xxx.dubbo.demo.service.impl;

import java.util.Date;

import com.xxx.dubbo.demo.service.GreetingService;

/**
 * @author wangmengjun
 *
 */
public class GreetingServiceImpl implements GreetingService {

	public String hello(String name) {
		System.out.println("Hello Service is calling : " + new Date());
		String greetMessage = "Hello, " + name;
		return greetMessage;
	}

}

配置XML文件

  • spring-dubbo-provider.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:dubbo="http://code.alibabatech.com/schema/dubbo"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://code.alibabatech.com/schema/dubbo
    http://code.alibabatech.com/schema/dubbo/dubbo.xsd
    ">

	<description>Dubbo Demo Service</description>
	<!-- 提供方应用信息,用于计算依赖关系 -->
	<dubbo:application name="dubbo-demo-provider" />

	<!-- 使用zookeeper注册中心暴露服务地址 -->
	<dubbo:registry protocol="zookeeper" address="127.0.0.1:2181"
		client="zkclient" />

	<!-- dubbo缓存 -->
	<dubbo:protocol id="dubbo" name="dubbo" port="20880"
		threadpool="cached" threads="100" />

	<!-- Greeting服务 -->
	<bean id="greetingService" class="com.xxx.dubbo.demo.service.impl.GreetingServiceImpl" />

	<dubbo:service protocol="dubbo"
		interface="com.xxx.dubbo.demo.service.GreetingService" ref="greetingService" />
</beans>
  • 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"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        ">
	<!--服务层配置 -->
	<import resource="classpath:spring-dubbo-provider.xml" />
</beans>

编写启动类

编写一个启动类Main

package com.xxx.dubbo.demo.main;

import java.io.IOException;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) throws IOException {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
				"applicationContext.xml");
		context.start();
		System.in.read();
	}
}

其中,

System.in.read(); 的作用是控制台输入任何字符退出~ 因为本文示例provider不是web工程,这个操作只是保持provider的服务一直开着~

接下来,我们继续来完成模块Consumer的代码和配置~

模块Consumer

添加依赖包

  • 添加interface依赖包
		<dependency>
			<groupId>com.xxx.dubbo.demo</groupId>
			<artifactId>dubbo-demo-interface</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
  • 添加spring依赖包
<!--引入Spring依赖包 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
  • 添加dubbo依赖包
        <!-- Dubbo相关 -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>dubbo</artifactId>
			<version>2.5.4-snapshot</version>
			<exclusions>
				<exclusion>
					<groupId>org.springframework</groupId>
					<artifactId>spring</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.javassist</groupId>
			<artifactId>javassist</artifactId>
			<version>3.18.1-GA</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/io.netty/netty -->
		<dependency>
			<groupId>io.netty</groupId>
			<artifactId>netty</artifactId>
			<version>3.10.6.Final</version>
		</dependency>
  • 添加zk-client依赖包
		<!-- ZK-client -->
		<dependency>
			<groupId>com.github.sgroschupf</groupId>
			<artifactId>zkclient</artifactId>
			<version>0.1</version>
		</dependency>

dubbo-demo-consumer模块详细的pom.xml文件如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.xxx.dubbo.demo</groupId>
    <artifactId>dubbo-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>dubbo-demo-consumer</artifactId>

   <properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<spring.framework.version>4.3.6.RELEASE</spring.framework.version>
	</properties>

	<dependencies>

		<dependency>
			<groupId>com.xxx.dubbo.demo</groupId>
			<artifactId>dubbo-demo-interface</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>

		<!--引入Spring依赖包 -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>

		<!-- Dubbo -->
		<dependency>
			<groupId>com.alibaba</groupId><artifactId>dubbo</artifactId><version>2.5.4-snapshot</version><exclusions><exclusion><groupId>org.springframework</groupId><artifactId>spring</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.javassist</groupId><artifactId>javassist</artifactId><version>3.18.1-GA</version></dependency><!-- https://mvnrepository.com/artifact/io.netty/netty --><dependency><groupId>io.netty</groupId><artifactId>netty</artifactId><version>3.10.6.Final</version></dependency><!-- ZK-client --><dependency><groupId>com.github.sgroschupf</groupId><artifactId>zkclient</artifactId><version>0.1</version></dependency></dependencies></project>

配置XML文件

  • spring-dubbo-consumer.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:dubbo="http://code.alibabatech.com/schema/dubbo"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://code.alibabatech.com/schema/dubbo
    http://code.alibabatech.com/schema/dubbo/dubbo.xsd
    ">

	<description>Dubbo Demo Service</description>
	<!-- 提供方应用信息,用于计算依赖关系 -->
	<dubbo:application name="DemoProvider" />

	<!-- 使用zookeeper注册中心暴露服务地址 -->
	<dubbo:registry protocol="zookeeper" address="127.0.0.1:2181"
		client="zkclient" />

	<!-- dubbo缓存 -->
	<dubbo:protocol id="dubbo" name="dubbo" port="20880"
		threadpool="cached" threads="100" />

	<!-- 生成远程服务代理,可以和本地bean一样使用demoService -->
	<dubbo:reference id="greetingService"
		interface="com.xxx.dubbo.demo.service.GreetingService" />

</beans>
  • 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"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        ">
	<!--服务层配置 -->
	<import resource="classpath:spring-dubbo-consumer.xml" />
</beans>

编写测试类

dubbo-demo-consumer模块下,创建一个调用interface接口的方法~

package com.xxx.dubbo.demo.main;

import java.io.IOException;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.xxx.dubbo.demo.service.GreetingService;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) throws IOException {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
		context.start();
		GreetingService greetingService = (GreetingService) context.getBean("greetingService");
		String greetMessage = greetingService.hello("Eric");
		System.out.println("Consumer ==> " + greetMessage);
		context.destroy();
	}
}

Zookeeper安装和配置

安装

可以从zookeeper官网下载zookeeper安装包~ 本文使用的版本是3.4.6, 将下载的安装包解压缩即可。

配置

进入Zookeeper安装目录下的conf目录~

复制zoo_sample.conf文件,并将复制的配置文件取名为zoo.conf~ 其内容如下:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

简单使用的话,可以不做修改~

至此,interface,provider以及consumer模块已经准备好,zookeeper也已经准备好~ 接下来就可以做相关的测试了~

测试 & 结果

启动Zookeeper

进入Zookeeper安装路径下的bin目录~

window系统中,启动zkServer.cmdLinux中,启动zkServer.sh~

启动zookeeper服务,

启动提供者

运行dubbo-demo-provider模块中的Main类~

  • 运行之后,出现如下问题:
log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
  • 根据描述 ,解决方法很简单,配置一个log4j.properties文件在resouce下即可

log4j.properties的内容简单如下:

# Rules reminder:
# DEBUG < INFO < WARN < ERROR < FATAL

# Global logging configuration
log4j.rootLogger=INFO,stdout

## Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%-5p][%d{yyyy-MM-dd HH:mm:ss,SSS}] %l - %m%n

重新运行Main类,可以看出来,provider已经成功启动~

[INFO ][2017-05-18 21:06:13,577] org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:582) - Refreshing org[email protected]46309a10: startup date [Thu May 18 21:06:13 CST 2017]; root of context hierarchy
[INFO ][2017-05-18 21:06:13,626] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317) - Loading XML bean definitions from class path resource [applicationContext.xml]
[INFO ][2017-05-18 21:06:13,717] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317) - Loading XML bean definitions from class path resource [spring-dubbo-provider.xml]
[INFO ][2017-05-18 21:06:13,779]  - using logger: com.alibaba.dubbo.common.logger.log4j.Log4jLoggerAdapter
[INFO ][2017-05-18 21:06:14,097] com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:107) -  [DUBBO] The service ready on spring started. service: com.xxx.dubbo.demo.service.GreetingService, dubbo version: 2.5.4-SNAPSHOT, current host: 127.0.0.1
[INFO ][2017-05-18 21:06:14,213] com.alibaba.dubbo.config.ServiceConfig.exportLocal(ServiceConfig.java:513) -  [DUBBO] Export dubbo service com.xxx.dubbo.demo.service.GreetingService to local registry, dubbo version: 2.5.4-SNAPSHOT, current host: 127.0.0.1
[INFO ][2017-05-18 21:06:14,213] com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:473) -  [DUBBO] Export dubbo service com.xxx.dubbo.demo.service.GreetingService to url dubbo://192.168.102.51:20880/com.xxx.dubbo.demo.service.GreetingService?anyhost=true&application=dubbo-demo-provider&dubbo=2.5.4-SNAPSHOT&generic=false&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=18448&side=provider&threadpool=cached&threads=100&timestamp=1495112774127, dubbo version: 2.5.4-SNAPSHOT, current host: 127.0.0.1
[INFO ][2017-05-18 21:06:14,214] com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:484) -  [DUBBO] Register dubbo service com.xxx.dubbo.demo.service.GreetingService url dubbo://192.168.102.51:20880/com.xxx.dubbo.demo.service.GreetingService?anyhost=true&application=dubbo-demo-provider&dubbo=2.5.4-SNAPSHOT&generic=false&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=18448&side=provider&threadpool=cached&threads=100&timestamp=1495112774127 to registry registry://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-demo-provider&client=zkclient&dubbo=2.5.4-SNAPSHOT&pid=18448&registry=zookeeper&timestamp=1495112774106, dubbo version: 2.5.4-SNAPSHOT, current host: 127.0.0.1
[INFO ][2017-05-18 21:06:14,397] com.alibaba.dubbo.remoting.transport.AbstractServer.<init>(AbstractServer.java:69) -  [DUBBO] Start NettyServer bind /0.0.0.0:20880, export /192.168.102.51:20880, dubbo version: 2.5.4-SNAPSHOT, current host: 127.0.0.1
[INFO ][2017-05-18 21:06:14,434] org.I0Itec.zkclient.ZkEventThread.run(ZkEventThread.java:64) - Starting ZkClient event thread.
[INFO ][2017-05-18 21:06:14,443] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:zookeeper.version=3.3.3-1073969, built on 02/23/2011 22:27 GMT
[INFO ][2017-05-18 21:06:14,443] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:host.name=wangmengjun-PC
[INFO ][2017-05-18 21:06:14,443] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.version=1.7.0_79
[INFO ][2017-05-18 21:06:14,443] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.vendor=Oracle Corporation
[INFO ][2017-05-18 21:06:14,444] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.home=C:\Program Files\Java\jre7
[INFO ][2017-05-18 21:06:14,444] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.class.path=F:\JavaDeveloper\workspaces\SpringMVCDubboExample\dubbo-demo\dubbo-demo-provider\target\classes;F:\JavaDeveloper\workspaces\SpringMVCDubboExample\dubbo-demo\dubbo-demo-interface\target\classes;D:\java_tools\Reponsitories\Maven\org\springframework\spring-core\4.3.6.RELEASE\spring-core-4.3.6.RELEASE.jar;D:\java_tools\Reponsitories\Maven\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;D:\java_tools\Reponsitories\Maven\org\springframework\spring-context\4.3.6.RELEASE\spring-context-4.3.6.RELEASE.jar;D:\java_tools\Reponsitories\Maven\org\springframework\spring-aop\4.3.6.RELEASE\spring-aop-4.3.6.RELEASE.jar;D:\java_tools\Reponsitories\Maven\org\springframework\spring-beans\4.3.6.RELEASE\spring-beans-4.3.6.RELEASE.jar;D:\java_tools\Reponsitories\Maven\org\springframework\spring-expression\4.3.6.RELEASE\spring-expression-4.3.6.RELEASE.jar;D:\java_tools\Reponsitories\Maven\com\alibaba\dubbo\2.5.4-snapshot\dubbo-2.5.4-snapshot.jar;D:\java_tools\Reponsitories\Maven\org\javassist\javassist\3.18.1-GA\javassist-3.18.1-GA.jar;D:\java_tools\Reponsitories\Maven\io\netty\netty\3.10.6.Final\netty-3.10.6.Final.jar;D:\java_tools\Reponsitories\Maven\com\github\sgroschupf\zkclient\0.1\zkclient-0.1.jar;D:\java_tools\Reponsitories\Maven\org\apache\zookeeper\zookeeper\3.3.3\zookeeper-3.3.3.jar;D:\java_tools\Reponsitories\Maven\jline\jline\0.9.94\jline-0.9.94.jar;D:\java_tools\Reponsitories\Maven\junit\junit\3.8.1\junit-3.8.1.jar;D:\java_tools\Reponsitories\Maven\log4j\log4j\1.2.14\log4j-1.2.14.jar
[INFO ][2017-05-18 21:06:14,444] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.library.path=C:\Program Files\Java\jre7\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Common Files\lenovo\easyplussdk\bin;.;C:\Program Files\Java\jdk1.7.0_79\bin;D:\develop\apache-jmeter-2.13\bin;C:\Program Files\TortoiseSVN\bin;D:\develop\Databases\Mysql\mysql-5.6.20\bin;D:\develop\Sonar\sonar-runner-2.4\bin;D:\develop\Sonar\sonarqube-5.1.1\bin;D:\develop\python\python-2.7.10\python.exe;C:\Program Files\TortoiseGit\bin;D:\develop\ZeroC\ZeroCIce-3.6.2\bin;D:\develop\apache-maven-3.3.3\bin;D:\develop\Sonar\sonar-scanner-2.8\bin;F:\JavaDeveloper\SQL\mysql-5.7.17-winx64\bin;F:\JavaDeveloper\Nodejs\nodejs7\;C:\Users\wangmengjun\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\wangmengjun\AppData\Local\Programs\Python\Python36\;C:\Users\wangmengjun\AppData\Local\Programs\Python\Python35\Scripts\;C:\Users\wangmengjun\AppData\Local\Programs\Python\Python35\;C:\Program Files (x86)\OpenVPN\bin;C:\Users\wangmengjun\AppData\Local\Microsoft\WindowsApps;C:\Users\wangmengjun\AppData\Roaming\npm;.
[INFO ][2017-05-18 21:06:14,444] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.io.tmpdir=C:\Users\WANGME~1\AppData\Local\Temp[INFO ][2017-05-18 21:06:14,444] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.compiler=<NA>
[INFO ][2017-05-18 21:06:14,444] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:os.name=Windows 8.1
[INFO ][2017-05-18 21:06:14,445] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:os.arch=amd64
[INFO ][2017-05-18 21:06:14,445] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:os.version=6.3
[INFO ][2017-05-18 21:06:14,445] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:user.name=wangmengjun
[INFO ][2017-05-18 21:06:14,445] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:user.home=C:\Users\wangmengjun
[INFO ][2017-05-18 21:06:14,445] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:user.dir=F:\JavaDeveloper\workspaces\SpringMVCDubboExample\dubbo-demo\dubbo-demo-provider
[INFO ][2017-05-18 21:06:14,446] org.apache.zookeeper.ZooKeeper.<init>(ZooKeeper.java:373) - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 [email protected]
[INFO ][2017-05-18 21:06:14,454] org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:1041) - Opening socket connection to server /127.0.0.1:2181
[INFO ][2017-05-18 21:06:14,456] org.apache.zookeeper.ClientCnxn$SendThread.primeConnection(ClientCnxn.java:949) - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session
[INFO ][2017-05-18 21:06:14,608] org.apache.zookeeper.ClientCnxn$SendThread.readConnectResult(ClientCnxn.java:738) - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x15c1ba12c860000, negotiated timeout = 30000
[INFO ][2017-05-18 21:06:14,610] org.I0Itec.zkclient.ZkClient.processStateChanged(ZkClient.java:449) - zookeeper state changed (SyncConnected)
[INFO ][2017-05-18 21:06:14,611] com.alibaba.dubbo.registry.support.AbstractRegistry.register(AbstractRegistry.java:302) -  [DUBBO] Register: dubbo://192.168.102.51:20880/com.xxx.dubbo.demo.service.GreetingService?anyhost=true&application=dubbo-demo-provider&dubbo=2.5.4-SNAPSHOT&generic=false&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=18448&side=provider&threadpool=cached&threads=100&timestamp=1495112774127, dubbo version: 2.5.4-SNAPSHOT, current host: 127.0.0.1
[INFO ][2017-05-18 21:06:14,699] com.alibaba.dubbo.registry.support.AbstractRegistry.subscribe(AbstractRegistry.java:325) -  [DUBBO] Subscribe: provider://192.168.102.51:20880/com.xxx.dubbo.demo.service.GreetingService?anyhost=true&application=dubbo-demo-provider&category=configurators&check=false&dubbo=2.5.4-SNAPSHOT&generic=false&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=18448&side=provider&threadpool=cached&threads=100&timestamp=1495112774127, dubbo version: 2.5.4-SNAPSHOT, current host: 127.0.0.1
[INFO ][2017-05-18 21:06:14,758] com.alibaba.dubbo.registry.support.AbstractRegistry.notify(AbstractRegistry.java:422) -  [DUBBO] Notify urls for subscribe url provider://192.168.102.51:20880/com.xxx.dubbo.demo.service.GreetingService?anyhost=true&application=dubbo-demo-provider&category=configurators&check=false&dubbo=2.5.4-SNAPSHOT&generic=false&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=18448&side=provider&threadpool=cached&threads=100&timestamp=1495112774127, urls: [empty://192.168.102.51:20880/com.xxx.dubbo.demo.service.GreetingService?anyhost=true&application=dubbo-demo-provider&category=configurators&check=false&dubbo=2.5.4-SNAPSHOT&generic=false&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=18448&side=provider&threadpool=cached&threads=100&timestamp=1495112774127], dubbo version: 2.5.4-SNAPSHOT, current host: 127.0.0.1

消费者调用

接下来,最后一个步骤就是在dubbo-demo-consumer中,调用Dubbo服务即可~

运行中的Main类,结果如下:

[INFO ][2017-05-18 21:08:45,916] org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:582) - Refreshing org[email protected]6ff58334: startup date [Thu May 18 21:08:45 CST 2017]; root of context hierarchy
[INFO ][2017-05-18 21:08:45,966] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317) - Loading XML bean definitions from class path resource [applicationContext.xml]
[INFO ][2017-05-18 21:08:46,059] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:317) - Loading XML bean definitions from class path resource [spring-dubbo-consumer.xml]
[INFO ][2017-05-18 21:08:46,118]  - using logger: com.alibaba.dubbo.common.logger.log4j.Log4jLoggerAdapter
[INFO ][2017-05-18 21:08:46,533] com.alibaba.dubbo.registry.support.AbstractRegistry.loadProperties(AbstractRegistry.java:232) -  [DUBBO] Load registry store file C:\Users\wangmengjun\.dubbo\dubbo-registry-127.0.0.1.cache, data: {com.xxx.dubbo.demo.service.GreetingService=empty://192.168.102.51:20880/com.xxx.dubbo.demo.service.GreetingService?anyhost=true&application=dubbo-demo-provider&category=configurators&check=false&dubbo=2.5.4-SNAPSHOT&generic=false&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=18448&side=provider&threadpool=cached&threads=100&timestamp=1495112774127}, dubbo version: 2.5.4-SNAPSHOT, current host: 127.0.0.1
[INFO ][2017-05-18 21:08:46,545] org.I0Itec.zkclient.ZkEventThread.run(ZkEventThread.java:64) - Starting ZkClient event thread.
[INFO ][2017-05-18 21:08:46,554] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:zookeeper.version=3.3.3-1073969, built on 02/23/2011 22:27 GMT
[INFO ][2017-05-18 21:08:46,554] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:host.name=wangmengjun-PC
[INFO ][2017-05-18 21:08:46,554] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.version=1.7.0_79
[INFO ][2017-05-18 21:08:46,554] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.vendor=Oracle Corporation
[INFO ][2017-05-18 21:08:46,554] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.home=C:\Program Files\Java\jre7
[INFO ][2017-05-18 21:08:46,555] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.class.path=F:\JavaDeveloper\workspaces\SpringMVCDubboExample\dubbo-demo\dubbo-demo-consumer\target\classes;F:\JavaDeveloper\workspaces\SpringMVCDubboExample\dubbo-demo\dubbo-demo-interface\target\classes;D:\java_tools\Reponsitories\Maven\org\springframework\spring-core\4.3.6.RELEASE\spring-core-4.3.6.RELEASE.jar;D:\java_tools\Reponsitories\Maven\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;D:\java_tools\Reponsitories\Maven\org\springframework\spring-context\4.3.6.RELEASE\spring-context-4.3.6.RELEASE.jar;D:\java_tools\Reponsitories\Maven\org\springframework\spring-aop\4.3.6.RELEASE\spring-aop-4.3.6.RELEASE.jar;D:\java_tools\Reponsitories\Maven\org\springframework\spring-beans\4.3.6.RELEASE\spring-beans-4.3.6.RELEASE.jar;D:\java_tools\Reponsitories\Maven\org\springframework\spring-expression\4.3.6.RELEASE\spring-expression-4.3.6.RELEASE.jar;D:\java_tools\Reponsitories\Maven\com\alibaba\dubbo\2.5.4-snapshot\dubbo-2.5.4-snapshot.jar;D:\java_tools\Reponsitories\Maven\org\javassist\javassist\3.18.1-GA\javassist-3.18.1-GA.jar;D:\java_tools\Reponsitories\Maven\io\netty\netty\3.10.6.Final\netty-3.10.6.Final.jar;D:\java_tools\Reponsitories\Maven\com\github\sgroschupf\zkclient\0.1\zkclient-0.1.jar;D:\java_tools\Reponsitories\Maven\org\apache\zookeeper\zookeeper\3.3.3\zookeeper-3.3.3.jar;D:\java_tools\Reponsitories\Maven\jline\jline\0.9.94\jline-0.9.94.jar;D:\java_tools\Reponsitories\Maven\junit\junit\3.8.1\junit-3.8.1.jar;D:\java_tools\Reponsitories\Maven\log4j\log4j\1.2.14\log4j-1.2.14.jar
[INFO ][2017-05-18 21:08:46,555] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.library.path=C:\Program Files\Java\jre7\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Common Files\lenovo\easyplussdk\bin;.;C:\Program Files\Java\jdk1.7.0_79\bin;D:\develop\apache-jmeter-2.13\bin;C:\Program Files\TortoiseSVN\bin;D:\develop\Databases\Mysql\mysql-5.6.20\bin;D:\develop\Sonar\sonar-runner-2.4\bin;D:\develop\Sonar\sonarqube-5.1.1\bin;D:\develop\python\python-2.7.10\python.exe;C:\Program Files\TortoiseGit\bin;D:\develop\ZeroC\ZeroCIce-3.6.2\bin;D:\develop\apache-maven-3.3.3\bin;D:\develop\Sonar\sonar-scanner-2.8\bin;F:\JavaDeveloper\SQL\mysql-5.7.17-winx64\bin;F:\JavaDeveloper\Nodejs\nodejs7\;C:\Users\wangmengjun\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\wangmengjun\AppData\Local\Programs\Python\Python36\;C:\Users\wangmengjun\AppData\Local\Programs\Python\Python35\Scripts\;C:\Users\wangmengjun\AppData\Local\Programs\Python\Python35\;C:\Program Files (x86)\OpenVPN\bin;C:\Users\wangmengjun\AppData\Local\Microsoft\WindowsApps;C:\Users\wangmengjun\AppData\Roaming\npm;.
[INFO ][2017-05-18 21:08:46,555] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.io.tmpdir=C:\Users\WANGME~1\AppData\Local\Temp[INFO ][2017-05-18 21:08:46,555] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:java.compiler=<NA>
[INFO ][2017-05-18 21:08:46,556] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:os.name=Windows 8.1
[INFO ][2017-05-18 21:08:46,556] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:os.arch=amd64
[INFO ][2017-05-18 21:08:46,556] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:os.version=6.3
[INFO ][2017-05-18 21:08:46,556] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:user.name=wangmengjun
[INFO ][2017-05-18 21:08:46,556] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:user.home=C:\Users\wangmengjun
[INFO ][2017-05-18 21:08:46,557] org.apache.zookeeper.Environment.logEnv(Environment.java:97) - Client environment:user.dir=F:\JavaDeveloper\workspaces\SpringMVCDubboExample\dubbo-demo\dubbo-demo-consumer
[INFO ][2017-05-18 21:08:46,558] org.apache.zookeeper.ZooKeeper.<init>(ZooKeeper.java:373) - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 [email protected]
[INFO ][2017-05-18 21:08:46,576] org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:1041) - Opening socket connection to server /127.0.0.1:2181
[INFO ][2017-05-18 21:08:46,578] org.apache.zookeeper.ClientCnxn$SendThread.primeConnection(ClientCnxn.java:949) - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session
[INFO ][2017-05-18 21:08:46,605] org.apache.zookeeper.ClientCnxn$SendThread.readConnectResult(ClientCnxn.java:738) - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x15c1ba12c860001, negotiated timeout = 30000
[INFO ][2017-05-18 21:08:46,607] org.I0Itec.zkclient.ZkClient.processStateChanged(ZkClient.java:449) - zookeeper state changed (SyncConnected)
[INFO ][2017-05-18 21:08:46,628] com.alibaba.dubbo.registry.support.AbstractRegistry.register(AbstractRegistry.java:302) -  [DUBBO] Register: consumer://192.168.102.51/com.xxx.dubbo.demo.service.GreetingService?application=DemoProvider&category=consumers&check=false&dubbo=2.5.4-SNAPSHOT&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=21572&side=consumer&timestamp=1495112926463, dubbo version: 2.5.4-SNAPSHOT, current host: 192.168.102.51
[INFO ][2017-05-18 21:08:46,702] com.alibaba.dubbo.registry.support.AbstractRegistry.subscribe(AbstractRegistry.java:325) -  [DUBBO] Subscribe: consumer://192.168.102.51/com.xxx.dubbo.demo.service.GreetingService?application=DemoProvider&category=providers,configurators,routers&dubbo=2.5.4-SNAPSHOT&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=21572&side=consumer&timestamp=1495112926463, dubbo version: 2.5.4-SNAPSHOT, current host: 192.168.102.51
[INFO ][2017-05-18 21:08:46,853] com.alibaba.dubbo.registry.support.AbstractRegistry.notify(AbstractRegistry.java:422) -  [DUBBO] Notify urls for subscribe url consumer://192.168.102.51/com.xxx.dubbo.demo.service.GreetingService?application=DemoProvider&category=providers,configurators,routers&dubbo=2.5.4-SNAPSHOT&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=21572&side=consumer&timestamp=1495112926463, urls: [dubbo://192.168.102.51:20880/com.xxx.dubbo.demo.service.GreetingService?anyhost=true&application=dubbo-demo-provider&dubbo=2.5.4-SNAPSHOT&generic=false&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=18448&side=provider&threadpool=cached&threads=100&timestamp=1495112774127, empty://192.168.102.51/com.xxx.dubbo.demo.service.GreetingService?application=DemoProvider&category=configurators&dubbo=2.5.4-SNAPSHOT&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=21572&side=consumer&timestamp=1495112926463, empty://192.168.102.51/com.xxx.dubbo.demo.service.GreetingService?application=DemoProvider&category=routers&dubbo=2.5.4-SNAPSHOT&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=21572&side=consumer&timestamp=1495112926463], dubbo version: 2.5.4-SNAPSHOT, current host: 192.168.102.51
[INFO ][2017-05-18 21:08:46,974] com.alibaba.dubbo.remoting.transport.AbstractClient.connect(AbstractClient.java:287) -  [DUBBO] Successed connect to server /192.168.102.51:20880 from NettyClient 192.168.102.51 using dubbo version 2.5.4-SNAPSHOT, channel is NettyChannel [channel=[id: 0x5830ab5f, /192.168.102.51:59578 => /192.168.102.51:20880]], dubbo version: 2.5.4-SNAPSHOT, current host: 192.168.102.51
[INFO ][2017-05-18 21:08:46,975] com.alibaba.dubbo.remoting.transport.AbstractClient.<init>(AbstractClient.java:105) -  [DUBBO] Start NettyClient wangmengjun-PC/192.168.102.51 connect to the server /192.168.102.51:20880, dubbo version: 2.5.4-SNAPSHOT, current host: 192.168.102.51
[INFO ][2017-05-18 21:08:47,030] com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:423) -  [DUBBO] Refer dubbo service com.xxx.dubbo.demo.service.GreetingService from url zookeeper://127.0.0.1:2181/com.alibaba.dubbo.registry.RegistryService?anyhost=true&application=DemoProvider&check=false&dubbo=2.5.4-SNAPSHOT&generic=false&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=21572&side=consumer&timestamp=1495112926463, dubbo version: 2.5.4-SNAPSHOT, current host: 192.168.102.51
Consumer ==> Hello, Eric
[INFO ][2017-05-18 21:08:47,140] org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:987) - Closing org[email protected]6ff58334: startup date [Thu May 18 21:08:45 CST 2017]; root of context hierarchy
[INFO ][2017-05-18 21:08:47,140] com.alibaba.dubbo.registry.support.AbstractRegistry.unsubscribe(AbstractRegistry.java:343) -  [DUBBO] Unsubscribe: consumer://192.168.102.51/com.xxx.dubbo.demo.service.GreetingService?application=DemoProvider&category=providers,configurators,routers&dubbo=2.5.4-SNAPSHOT&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=21572&side=consumer&timestamp=1495112926463, dubbo version: 2.5.4-SNAPSHOT, current host: 192.168.102.51
[INFO ][2017-05-18 21:08:47,141] com.alibaba.dubbo.remoting.transport.netty.NettyChannel.close(NettyChannel.java:135) -  [DUBBO] Close netty channel [id: 0x5830ab5f, /192.168.102.51:59578 => /192.168.102.51:20880], dubbo version: 2.5.4-SNAPSHOT, current host: 192.168.102.51
[INFO ][2017-05-18 21:08:47,143] com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.disconnected(DubboProtocol.java:130) -  [DUBBO] disconected from /192.168.102.51:20880,url:dubbo://192.168.102.51:20880/com.xxx.dubbo.demo.service.GreetingService?anyhost=true&application=DemoProvider&check=false&codec=dubbo&dubbo=2.5.4-SNAPSHOT&generic=false&heartbeat=60000&interface=com.xxx.dubbo.demo.service.GreetingService&methods=hello&pid=21572&side=consumer&timestamp=1495112926463, dubbo version: 2.5.4-SNAPSHOT, current host: 192.168.102.51

从上述日志中可以看出,hello接口已经成功调用,并输出了Consumer ==> Hello, Eric

当然,我们可以切换到provider的输出日志,包含hello方法被调用执行的时间信息~

Hello Service is calling : Thu May 18 21:08:47 CST 2017

至此,一个简单的Maven + Spring + Dubbb + Zookeeper整合示例就完成了。后续,可以将provider变成一个Web工程,如springMVC实现等,其中可以和MySQL或者NoSQL(如MongoDB等)集成,进一步完成其它功能~

问题解决参考

No appenders could be found for logger

log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.

根据描述 ,解决方法很简单,配置一个log4j.properties文件在resouce下即可

log4j.properties的内容简单如下:

# Rules reminder:
# DEBUG < INFO < WARN < ERROR < FATAL

# Global logging configuration
log4j.rootLogger=INFO,stdout

## Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%-5p][%d{yyyy-MM-dd HH:mm:ss,SSS}] %l - %m%n

dubbo标签xml配置文件报错

参考博文【Dubbo标签在xml配置文件中报错的解决方法

整个工程结构

? 著作权归作者所有

时间: 2024-10-06 23:25:17

一步步完成Maven+Spring+Dubbo+Zookeeper的整合示例的相关文章

mybatis学习笔记(六) -- maven+spring+mybatis从零开始搭建整合详细过程(下)

继续 mybatis学习笔记(五) -- maven+spring+mybatis从零开始搭建整合详细过程(上) 五.使用监听器启动Spring容器 1.修改pom.xml文件,添加Spring-web 2.修改web.xml,配置启动Spring容器 3.新建BookServer 4.新建BookServlet 5.修改ApplicationContext.xml 6.测试 继续!!! 五.使用监听器启动Spring容器 1.修改pom.xml,添加Spring-web包(注:上一篇中的pom

jfware开始篇: hibernate4.1.9 + spring 3.2.2整合示例(CRUD)

原文:jfware开始篇: hibernate4.1.9 + spring 3.2.2整合示例(CRUD) 源代码下载地址:http://www.zuidaima.com/share/1550463702518784.htm 最近看了这篇文章,决定多动动手,顺便复习一下. 本人技术不牛,还请牛友多多指教. 完整的jar: 链接:http://pan.baidu.com/share/link?shareid=4248170828&uk=402880896 密码:ehqc 源码截图

maven+springmvc+dubbo+zookeeper

为什么要用dubbo? 还是让官方来解释吧: http://dubbo.io/User+Guide-zh.htm   http://dubbo.io/ 一般 nginx+tomcat  | ----> Controller1--------->service1 请求----->nginx  |  |----->Controller2--------->service2 请求进了Controller 就只有一条路可以走了 使用dubbo后 | ------->servic

mybatis学习笔记(五) -- maven+spring+mybatis从零开始搭建整合详细过程(附demo和搭建过程遇到的问题解决方法)

文章介绍结构一览 一.使用maven创建web项目 1.新建maven项目 2.修改jre版本 3.修改Project Facts,生成WebContent文件夾 4.将WebContent下的两个文件复制到src/main/webapp下,删掉WebContent 5.修改Deployment Assembly 6.测试 二.mybatis访问mysql 1.数据库准备 2.修改pom.xml 3.创建实体类 4.创建访问接口 5.添加映射文件 6.添加MyBatisCfg.xml配置文件,注

160719、Spring + Dubbo + zookeeper (linux) 框架搭建

转载一篇博客,写得不错(至少我参考一下搭建成功了) 转载地址:http://my.oschina.net/wangt10/blog/522799 dubbo简介 节点角色说明: Provider: 暴露服务的服务提供方. Consumer: 调用远程服务的服务消费方. Registry: 服务注册与发现的注册中心. Monitor: 统计服务的调用次调和调用时间的监控中心. Container: 服务运行容器. 调用关系说明: 0. 服务容器负责启动,加载,运行服务提供者. 1. 服务提供者在启

dubbo+zookeeper+spring+springMVC+mybatis的使用

读前声明:由于本人水平有限,有错误或者描述不恰当的地方请指出来,勿喷!第一次写博客. 源码下载链接:http://files.cnblogs.com/files/la-tiao-jun-blog/dubbo%E4%BE%8B%E5%AD%90.rar 使用条件: eclipse-jee-luna-SR2-win32-x86_64 jdk1.7,Apache Tomcat v8.0,maven zookeeper3.4.6 dubbo-2.4.10 dubbo-monitor-simple-2.5

分布式框架 Maven Springmvc mybatis ,Dubbo ZooKeeper,Redis,FastDFS ,ActiveMQ

平台简介 Jeesz是一个分布式的框架,提供项目模块化.服务化.热插拔的思想,高度封装安全性的Java EE快速开发平台. Jeesz本身集成Dubbo服务管控.Zookeeper注册中心.Redis分布式缓存技术.FastDFS分布式文件系统.ActiveMQ异步消息中间件.Nginx负载均衡等分布式技术 使用Maven做项目管理,项目模块化,提高项目的易开发性.扩展性 以Spring Framework为核心容器,Spring MVC为模型视图控制器,MyBatis为数据访问层, Apach

【精华】经典企业分布式框架Maven Springmvc mybatis,Dubbo ZooKeeper,Redis,FastDFS,ActiveMQ

开发工具 1.Eclipse IDE:采用Maven项目管理,模块化. 2.代码生成:通过界面方式简单配置,自动生成相应代码,目前包括三种生成方式(增删改查):单表.一对多.树结构.生成后的代码如果不需要注意美观程度,生成后即可用. 技术选型(只列了一部分技术) 1.后端 服务框架:Dubbo.zookeeper.Rest服务 缓存:Redis.ehcache 消息中间件:ActiveMQ 负载均衡:Nginx 分布式文件:FastDFS 数据库连接池:Alibaba Druid 1.0 核心框

用dubbo+zookeeper+spring搭建一个简单的http接口程序

dubbo是一个分布式服务框架,是阿里巴巴开发的一个解决RPC远程调用优化的核心框架,包含负载均衡算法,能提高分布式系统的性能. zookeeper是hadoop的一个子项目,主要用来解决分布式系统的数据一致性.状态同步.服务集群管理.配置同步等一系列的问题.本文使用zookeeper作为dubbo的服务注册中心. 技术细节方面: dubbo:http://www.dubbo.io zookeeper:http://www.ibm.com/developerworks/cn/opensource