增加 spring cloud 用例
This commit is contained in:
22
spring-cloud/spring-cloud-sleuth-zipkin/common/pom.xml
Normal file
22
spring-cloud/spring-cloud-sleuth-zipkin/common/pom.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.heibaiying.sleuth.zipkin</groupId>
|
||||
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
@ -0,0 +1,14 @@
|
||||
package com.heibaiying.common;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class CommonApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CommonApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.heibaiying.common.bean;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author : heibaiying
|
||||
* @description : 产品实体类
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Product implements Serializable {
|
||||
|
||||
// 产品序列号
|
||||
private long id;
|
||||
|
||||
// 产品名称
|
||||
private String name;
|
||||
|
||||
// 是否贵重品
|
||||
private Boolean isPrecious;
|
||||
|
||||
//生产日期
|
||||
private Date dateInProduced;
|
||||
|
||||
//产品价格
|
||||
private float price;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.heibaiying.common.feign;
|
||||
|
||||
import com.heibaiying.common.bean.Product;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : heibaiying
|
||||
* @description : 声明式接口调用
|
||||
*/
|
||||
public interface ProductFeign {
|
||||
|
||||
@GetMapping("products")
|
||||
List<Product> productList();
|
||||
|
||||
/**
|
||||
* 这是需要强调的是使用feign时候@PathVariable一定要用value指明参数,
|
||||
* 不然会抛出.IllegalStateException: PathVariable annotation was empty on param 异常
|
||||
*/
|
||||
@GetMapping("product/{id}")
|
||||
Product productDetail(@PathVariable(value = "id") int id);
|
||||
|
||||
|
||||
@PostMapping("product")
|
||||
void save(@RequestBody Product product);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.heibaiying.common;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class CommonApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user