Skip to content

Commit

Permalink
Add event trace spring boot starter usage document
Browse files Browse the repository at this point in the history
  • Loading branch information
TeslaCN committed Jul 19, 2020
1 parent 0f73d35 commit ec826fd
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
+++
title = "Spring Boot Starter"
title = "使用 Spring Boot Starter"
weight = 2
chapter = true
+++

TODO
ElasticJob-Lite 提供了自动配置 TracingConfiguration 的 Tracing Spring Boot Starter,
开发者只需注册一个 DataSource 到 Spring 容器中,
Starter 就会自动创建一个 TracingConfiguration 并注册到 Spring 容器中。

## 引入 elasticjob-tracing-spring-boot-starter

```xml
<dependency>
<groupId>org.apache.shardingsphere.elasticjob</groupId>
<artifactId>elasticjob-tracing-spring-boot-starter</artifactId>
<version>${elasticjob.latest.version}</version>
</dependency>
```

## 借助 spring-boot-starter-jdbc 注册 DataSource

引入依赖:
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>${springboot.version}</version>
</dependency>
```

配置 DataSource:
```yaml
spring:
datasource:
url: jdbc:h2:mem:job_event_storage
driver-class-name: org.h2.Driver
username: sa
password:
```

## 使用

TracingConfiguration 会自动注册到容器中,如果与 elasticjob-lite-spring-boot-starter 配合使用,
开发者无需进行其他额外的操作,作业启动器会自动使用创建的 TracingConfiguration。
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
+++
title = "Spring Boot Starter"
title = "Use Spring Boot Starter"
weight = 2
chapter = true
+++

TODO
ElasticJob-Lite provides a Spring Boot Starter to configure TracingConfiguration automatically.
What developers need to do is register a bean of DataSource into the Spring IoC Container.
Then the Starter will create an instance of TracingConfiguration and register it into the container.

## Introduce elasticjob-tracing-spring-boot-starter dependency

```xml
<dependency>
<groupId>org.apache.shardingsphere.elasticjob</groupId>
<artifactId>elasticjob-tracing-spring-boot-starter</artifactId>
<version>${elasticjob.latest.version}</version>
</dependency>
```

## Register DataSource via spring-boot-starter-jdbc

Introduce dependency:
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>${springboot.version}</version>
</dependency>
```

Configure DataSource:
```yaml
spring:
datasource:
url: jdbc:h2:mem:job_event_storage
driver-class-name: org.h2.Driver
username: sa
password:
```

## Usage

TracingConfiguration will be registered into the IoC container imperceptibly.
If elasticjob-lite-spring-boot-starter was introduced, developers need to do nothing else.
The instances of JobBootstrap will use the TracingConfiguration automatically.

0 comments on commit ec826fd

Please sign in to comment.