Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
武汉红喜
whatsmars
提交
2e908ce0
W
whatsmars
项目概览
武汉红喜
/
whatsmars
通知
3
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
whatsmars
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2e908ce0
编写于
9月 14, 2017
作者:
S
shenhongxi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
springcloud feign
上级
c3507b41
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
0 deletion
+30
-0
whatsmars-spring-cloud/whatsmars-springcloud-consumer/pom.xml
...smars-spring-cloud/whatsmars-springcloud-consumer/pom.xml
+5
-0
whatsmars-spring-cloud/whatsmars-springcloud-consumer/src/main/java/com/itlong/whatsmars/springcloud/consumer/ConsumerApplication.java
...g/whatsmars/springcloud/consumer/ConsumerApplication.java
+2
-0
whatsmars-spring-cloud/whatsmars-springcloud-consumer/src/main/java/com/itlong/whatsmars/springcloud/consumer/controller/DemoController.java
...smars/springcloud/consumer/controller/DemoController.java
+9
-0
whatsmars-spring-cloud/whatsmars-springcloud-consumer/src/main/java/com/itlong/whatsmars/springcloud/consumer/feign/DemoFeign.java
...tlong/whatsmars/springcloud/consumer/feign/DemoFeign.java
+14
-0
未找到文件。
whatsmars-spring-cloud/whatsmars-springcloud-consumer/pom.xml
浏览文件 @
2e908ce0
...
...
@@ -28,6 +28,11 @@
<artifactId>
spring-cloud-starter-eureka-server
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-feign
</artifactId>
</dependency>
<!--<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
...
...
whatsmars-spring-cloud/whatsmars-springcloud-consumer/src/main/java/com/itlong/whatsmars/springcloud/consumer/ConsumerApplication.java
浏览文件 @
2e908ce0
...
...
@@ -4,12 +4,14 @@ import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.client.loadbalancer.LoadBalanced
;
import
org.springframework.cloud.netflix.feign.EnableFeignClients
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.web.client.RestTemplate
;
/**
* Created by shenhongxi on 2017/9/14.
*/
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
public
class
ConsumerApplication
{
...
...
whatsmars-spring-cloud/whatsmars-springcloud-consumer/src/main/java/com/itlong/whatsmars/springcloud/consumer/controller/DemoController.java
浏览文件 @
2e908ce0
package
com.itlong.whatsmars.springcloud.consumer.controller
;
import
com.itlong.whatsmars.springcloud.consumer.feign.DemoFeign
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -17,8 +18,16 @@ public class DemoController {
// @Value("${foo}")
// private String foo;
@Autowired
private
DemoFeign
demoFeign
;
@RequestMapping
(
"/hello"
)
public
String
hello
(
String
name
)
{
return
restTemplate
.
getForObject
(
"http://demo-provider/hello?name="
+
name
,
String
.
class
);
}
@RequestMapping
(
"/hi"
)
public
String
hi
(
String
name
)
{
return
demoFeign
.
hello
(
name
);
}
}
whatsmars-spring-cloud/whatsmars-springcloud-consumer/src/main/java/com/itlong/whatsmars/springcloud/consumer/feign/DemoFeign.java
0 → 100644
浏览文件 @
2e908ce0
package
com.itlong.whatsmars.springcloud.consumer.feign
;
import
org.springframework.cloud.netflix.feign.FeignClient
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
* Created by shenhongxi on 2017/9/14.
*/
@FeignClient
(
"demo-provider"
)
public
interface
DemoFeign
{
@RequestMapping
(
"/hello"
)
String
hello
(
@RequestParam
(
name
=
"name"
)
String
name
);
// 此处必须有RequestParam
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录