Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
SpringCloudServerConsumer
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiachenqi
SpringCloudServerConsumer
Commits
0793034b
Commit
0793034b
authored
Jul 04, 2019
by
XCQi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现Feign远程调用后台接口功能
通过serviceId自动查询erueka中注册的服务列表并负载均衡调用
parent
cf967f6b
Pipeline
#46
canceled with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
0 deletions
+35
-0
SpringCloudConsumerApplication.java
...n/springcloudconsumer/SpringCloudConsumerApplication.java
+4
-0
RestApi.java
...a/com/yingxin/springcloudconsumer/controller/RestApi.java
+20
-0
HelloService.java
...com/yingxin/springcloudconsumer/service/HelloService.java
+11
-0
No files found.
src/main/java/com/yingxin/springcloudconsumer/SpringCloudConsumerApplication.java
View file @
0793034b
...
...
@@ -2,8 +2,12 @@ package com.yingxin.springcloudconsumer;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
public
class
SpringCloudConsumerApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
src/main/java/com/yingxin/springcloudconsumer/controller/RestApi.java
0 → 100644
View file @
0793034b
package
com
.
yingxin
.
springcloudconsumer
.
controller
;
import
com.yingxin.springcloudconsumer.service.HelloService
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
public
class
RestApi
{
private
final
HelloService
helloService
;
public
RestApi
(
HelloService
helloService
)
{
this
.
helloService
=
helloService
;
}
@GetMapping
(
"/consumer"
)
public
String
helloConsumer
()
{
return
helloService
.
hello
();
}
}
src/main/java/com/yingxin/springcloudconsumer/service/HelloService.java
0 → 100644
View file @
0793034b
package
com
.
yingxin
.
springcloudconsumer
.
service
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
@FeignClient
(
"spring-cloud-server-HelloWorld"
)
public
interface
HelloService
{
@GetMapping
(
"hello"
)
String
hello
();
}
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