Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spring-cloud-learn
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
spring-cloud-learn
Commits
2010dd3d
Commit
2010dd3d
authored
Aug 29, 2019
by
duanledexianxianxian
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add 服务注册与服务发现
parent
66b8deb1
Pipeline
#97
failed
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
2 deletions
+3
-2
spring-cloud-hello-world/hello-consumer-feign/src/main/java/com/duanledexian/spring/cloud/producer/api/IHelloApi.java
...com/duanledexian/spring/cloud/producer/api/IHelloApi.java
+2
-1
spring-cloud-hello-world/hello-consumer/src/main/java/com/duanledexian/spring/cloud/producer/controller/HomeController.java
...xian/spring/cloud/producer/controller/HomeController.java
+1
-1
No files found.
spring-cloud-hello-world/hello-consumer-feign/src/main/java/com/duanledexian/spring/cloud/producer/api/IHelloApi.java
View file @
2010dd3d
...
@@ -2,6 +2,7 @@ package com.duanledexian.spring.cloud.producer.api;
...
@@ -2,6 +2,7 @@ package com.duanledexian.spring.cloud.producer.api;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
/**
* The interface Hello api.
* The interface Hello api.
...
@@ -18,6 +19,6 @@ public interface IHelloApi {
...
@@ -18,6 +19,6 @@ public interface IHelloApi {
* @return the string
* @return the string
*/
*/
@GetMapping
(
"/api/v1/sayHello"
)
@GetMapping
(
"/api/v1/sayHello"
)
String
sayHello
(
String
name
);
String
sayHello
(
@RequestParam
(
"name"
)
String
name
);
}
}
spring-cloud-hello-world/hello-consumer/src/main/java/com/duanledexian/spring/cloud/producer/controller/HomeController.java
View file @
2010dd3d
...
@@ -27,7 +27,7 @@ public class HomeController {
...
@@ -27,7 +27,7 @@ public class HomeController {
@GetMapping
(
"/sayHello"
)
@GetMapping
(
"/sayHello"
)
public
String
sayHello
(
String
name
)
{
public
String
sayHello
(
String
name
)
{
name
+=
"!"
;
name
+=
"!"
;
ServiceInstance
instance
=
client
.
choose
(
"service-
consum
er"
);
ServiceInstance
instance
=
client
.
choose
(
"service-
produc
er"
);
String
url
=
"http://"
+
instance
.
getHost
()
+
":"
+
instance
.
getPort
()
+
"/api/v1/sayHello?name="
+
name
;
String
url
=
"http://"
+
instance
.
getHost
()
+
":"
+
instance
.
getPort
()
+
"/api/v1/sayHello?name="
+
name
;
return
restTemplate
.
getForObject
(
url
,
String
.
class
);
return
restTemplate
.
getForObject
(
url
,
String
.
class
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment