jimtse
网站页面
Zookeeper下载
解压并启动zookeeper
tar -zxf zookeeper-3.4.14.tar.gz
cd zookeeper-3.4.14
./bin/zkServer.sh start
<dependencies>
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.11</version>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.10</version>
</dependency>
</dependencies>
public interface IHelloService {
String sayHello(String name);
}
<dependencies>
<dependency>
<groupId>com.tse</groupId>
<artifactId>dubbo-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
spring.dubbo.appname=dubbo-provider
spring.dubbo.registry=zookeeper://localhost:2181
@Service
@Component
public class HelloServiceImpl implements IHelloService {
public String sayHello(String name){
return "hello" + name;
}
}
@SpringBootApplication
@EnableDubboConfiguration
public class Provider {
public static void main(String[] args) throws InterruptedException {
SpringApplication.run(Provider.class,args);
new CountDownLatch(1).await();
}
}
<dependencies>
<dependency>
<groupId>com.tse</groupId>
<artifactId>dubbo-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.3.RELEASE</version>
</dependency>
</dependencies>
spring.dubbo.appname=dubbo-consumer
spring.dubbo.registry=zookeeper://localhost:2181
@RestController
@RequestMapping("/hello")
public class HelloController {
@Reference
IHelloService iHelloService;
@RequestMapping
public String hello(@RequestParam String name){
return iHelloService.sayHello(name);
}
}
@SpringBootApplication
@EnableDubboConfiguration
public class Consumer {
public static void main(String[] args) throws InterruptedException {
SpringApplication.run(Consumer.class, args);
}
}