增加 spring cloud 用例

This commit is contained in:
罗祥
2019-01-15 14:17:17 +08:00
parent 0004596d6f
commit 78f9e43988
34 changed files with 141 additions and 61 deletions

View File

@ -17,7 +17,7 @@ import java.util.Date;
public class Product implements Serializable {
// 产品序列号
private int id;
private long id;
// 产品名称
private String name;

View File

@ -1,8 +1,7 @@
package com.heibaiying.common.feign;
import com.heibaiying.common.bean.Product;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -12,13 +11,17 @@ import java.util.List;
*/
public interface ProductFeign {
@RequestMapping("products")
@GetMapping("products")
List<Product> productList();
/**
* 这是需要强调的是使用feign时候@PathVariable一定要用value指明参数
* 不然会抛出.IllegalStateException: PathVariable annotation was empty on param 异常
*/
@RequestMapping("product/{id}")
@GetMapping("product/{id}")
Product productDetail(@PathVariable(value = "id") int id);
@PostMapping("product")
void save(@RequestBody Product product);
}