Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1a5d0db

Browse files
增加dubbo配置及相关文件
1 parent 2c4bc95 commit 1a5d0db

File tree

6 files changed

+85
-0
lines changed

6 files changed

+85
-0
lines changed

‎pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@
249249
<version>3.1.0</version>
250250
</dependency>
251251

252+
<dependency>
253+
<groupId>com.alibaba.boot</groupId>
254+
<artifactId>dubbo-spring-boot-starter</artifactId>
255+
<version>0.2.0</version>
256+
</dependency>
257+
252258
</dependencies>
253259
<build>
254260
<finalName>geek-framework</finalName>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.geekcattle.dubbo.bootstarp;
2+
3+
import org.springframework.boot.WebApplicationType;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.builder.SpringApplicationBuilder;
6+
7+
@SpringBootApplication
8+
public class DemoProvider {
9+
10+
public static void main(String[] args) {
11+
new SpringApplicationBuilder(DemoProvider.class).web(WebApplicationType.NONE).run(args);
12+
}
13+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.geekcattle.dubbo.controller;
2+
3+
import com.alibaba.dubbo.config.annotation.Reference;
4+
import com.geekcattle.dubbo.service.DemoService;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.RestController;
7+
8+
@RestController
9+
public class CustomerController {
10+
11+
12+
//url = "dubbo://localhost:12345" registry = "${dubbo.registry.address}"
13+
@Reference(url = "dubbo://localhost:12345", check = false)
14+
private DemoService demoService;
15+
16+
@RequestMapping("/sayHello")
17+
public String sayHello() {
18+
return demoService.sayHello("dubbo");
19+
}
20+
21+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.geekcattle.dubbo.service;
2+
3+
public interface DemoService {
4+
5+
String sayHello(String name);
6+
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.geekcattle.dubbo.service.impl;
2+
3+
import com.alibaba.dubbo.config.annotation.Service;
4+
import com.geekcattle.dubbo.service.DemoService;
5+
6+
@Service(
7+
protocol = "${dubbo.protocol.id}",
8+
registry = "${dubbo.registry.id}"
9+
)
10+
public class DemoServiceImpl implements DemoService {
11+
@Override
12+
public String sayHello(String name) {
13+
return "Hello, " + name + " (from Spring Boot)";
14+
}
15+
}

‎src/main/resources/application.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ spring:
6868
min-idle : 0
6969
# 连接超时时间(毫秒)
7070
timeout : 500ms
71+
application:
72+
name: geekcattle
73+
7174

7275
#mybaties配置
7376
mybatis:
@@ -180,6 +183,26 @@ j2cache:
180183
redis-client : lettuce
181184

182185

186+
187+
dubbo:
188+
application:
189+
id: dubbo-provide-demo
190+
name: dubbo-provide-demo
191+
qos-enable: true
192+
qos-port: 22222
193+
protocol:
194+
id: dubbo
195+
name: dubbo
196+
port: 12345
197+
status: server
198+
registry:
199+
address: zookeeper://121.41.17.147:2181
200+
id: my-registry
201+
scan:
202+
base-packages: com.geekcattle.dubbo.service.impl
203+
204+
205+
183206
---
184207

185208
#开发环境

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /