forked from yudaocode/SpringBoot-Labs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
YunaiV
committed
Mar 21, 2020
1 parent
c3e8aa3
commit b2397fc
Showing
6 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?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"> | ||
<parent> | ||
<artifactId>labx-13</artifactId> | ||
<groupId>cn.iocoder.springboot.labs</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>labx-13-sc-sleuth-sampler</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<spring.boot.version>2.2.4.RELEASE</spring.boot.version> | ||
<spring.cloud.version>Hoxton.SR1</spring.cloud.version> | ||
</properties> | ||
|
||
<!-- | ||
引入 Spring Boot、Spring Cloud、Spring Cloud Alibaba 三者 BOM 文件,进行依赖版本的管理,防止不兼容。 | ||
在 https://dwz.cn/mcLIfNKt 文章中,Spring Cloud Alibaba 开发团队推荐了三者的依赖关系 | ||
--> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>${spring.boot.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>${spring.cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<!-- 引入 SpringMVC 相关依赖,并实现对其的自动配置 --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<!-- 引入 Spring Cloud Sleuth + Zipkin 相关依赖,实现对它们的自动配置,从而实现链路追踪 --> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-zipkin</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
...ler/src/main/java/cn/iocoder/springcloud/labx13/springmvcdemo/UserServiceApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package cn.iocoder.springcloud.labx13.springmvcdemo; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class UserServiceApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(UserServiceApplication.class, args); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
.../src/main/java/cn/iocoder/springcloud/labx13/springmvcdemo/controller/UserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cn.iocoder.springcloud.labx13.springmvcdemo.controller; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/user") | ||
public class UserController { | ||
|
||
@GetMapping("/get") | ||
public String get(@RequestParam("id") Integer id) { | ||
return "user:" + id; | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
labx-13/labx-13-sc-sleuth-sampler/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
spring: | ||
application: | ||
name: user-service # 服务名 | ||
|
||
# Zipkin 配置项,对应 ZipkinProperties 类 | ||
zipkin: | ||
base-url: http://127.0.0.1:9411 # Zipkin 服务的地址 | ||
|
||
# Spring Cloud Sleuth 配置项 | ||
sleuth: | ||
# Spring Cloud Sleuth 针对 Web 组件的配置项,例如说 SpringMVC | ||
web: | ||
enabled: true # 是否开启,默认为 true | ||
# Spring Cloud Sleuth 针对抽样收集的配置项 | ||
sampler: | ||
probability: 0.1 # 采样百分比,默认为 1.0 全部采样。 | ||
rate: # 限流采样,即每秒可收集链路的数量,默认为 10。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters