Skip to content

Commit 6e4006b

Browse files
committed
增加从页面看到dubbo远程调用效果
1 parent 3410626 commit 6e4006b

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.spring.springboot.controller;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.spring.springboot.dubbo.CityDubboConsumerService;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.web.bind.annotation.RequestMapping;
8+
import org.springframework.web.bind.annotation.RestController;
9+
10+
11+
/**
12+
* Spring Boot HelloWorld 案例
13+
*
14+
* Created by bysocket on 16/4/26.
15+
*/
16+
@RestController
17+
public class HelloWorldController {
18+
19+
20+
@Autowired
21+
public CityDubboConsumerService cityService ;
22+
23+
private static final Logger logger = LoggerFactory.getLogger(HelloWorldController.class);
24+
25+
@RequestMapping("/")
26+
public String sayHello() {
27+
logger.info("invoke HelloWorldController # sayHello");
28+
cityService.printCity();
29+
logger.info(":::cityService.printCity() has been invoked");
30+
return "Hello,World!";
31+
}
32+
33+
@RequestMapping("/hi")
34+
public String sayHi() {
35+
logger.info("invoke HelloWorldController # sayHi");
36+
return "Hi,World!";
37+
}
38+
}

springboot-dubbo-client/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ server.port=8081
55

66
spring.dubbo.application.name=consumer
77
spring.dubbo.registry.address=zookeeper://127.0.0.1:2181
8-
spring.dubbo.scan=org.spring.springboot.dubbo
8+
spring.dubbo.scan=org.spring.springboot

0 commit comments

Comments
 (0)