码迷,mamicode.com
首页 > 编程语言 > 详细

springcloud基础入门

时间:2018-09-11 00:58:33      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:alt   技术   str   getter   提供者   服务提供者   img   实体   服务   

1.环境搭建
在开始SpringCloud之前,先看一下一个简单的服务提供者和服务消费者。服务提供者提供一个REST风格的HTTP接口给服务消费者。
技术分享图片
1.2pom配置



实体类

package com.test.springcloud.provider.pojo;

public class User {
private Long id;
private String username;
//getter/setter略

}
controller层

package com.test.springcloud.provider.controller;

import com.test.springcloud.provider.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
@GetMapping("/simple/{id}")//rest 风格,微服务一般都使用 rest 风格
public User findById(@PathVariable Long id) {
User user=new User();
user.setId(id);
user.setUsername("hello "+id);
return user;
}
}

springcloud基础入门

标签:alt   技术   str   getter   提供者   服务提供者   img   实体   服务   

原文地址:https://www.cnblogs.com/blackCatFish/p/9623458.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!