Skip to content

Commit

Permalink
update guide-java-spring-boot (#16128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Weaxs authored Jan 30, 2024
1 parent 34645f6 commit d0766c1
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions develop/dev-guide-sample-application-java-spring-boot.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ cd tidb-java-springboot-jpa-quickstart
6. 复制并粘贴对应连接字符串至 `env.sh` 中。需更改部分示例结果如下:

```shell
export TIDB_HOST='{host}' # e.g. gateway01.ap-northeast-1.prod.aws.tidbcloud.com
export TIDB_HOST='{host}' # e.g. xxxxxx.aws.tidbcloud.com
export TIDB_PORT='4000'
export TIDB_USER='{user}' # e.g. xxxxxx.root
export TIDB_PASSWORD='{password}'
Expand Down Expand Up @@ -113,9 +113,9 @@ cd tidb-java-springboot-jpa-quickstart
5. 复制并粘贴对应的连接字符串至 `env.sh` 中。需更改部分示例结果如下:

```shell
export TIDB_HOST='{host}' # e.g. tidb.xxxx.clusters.tidb-cloud.com
export TIDB_HOST='{host}' # e.g. xxxxxx.aws.tidbcloud.com
export TIDB_PORT='4000'
export TIDB_USER='{user}' # e.g. root
export TIDB_USER='{user}' # e.g. xxxxxx.root
export TIDB_PASSWORD='{password}'
export TIDB_DB_NAME='test'
export USE_SSL='false'
Expand All @@ -138,9 +138,9 @@ cd tidb-java-springboot-jpa-quickstart
2. 复制并粘贴对应 TiDB 的连接字符串至 `env.sh` 中。需更改部分示例结果如下:

```shell
export TIDB_HOST='{host}'
export TIDB_HOST='{host}' # e.g. xxxxxx.aws.tidbcloud.com
export TIDB_PORT='4000'
export TIDB_USER='root'
export TIDB_USER='root' # e.g. xxxxxx.root
export TIDB_PASSWORD='{password}'
export TIDB_DB_NAME='test'
export USE_SSL='false'
Expand Down Expand Up @@ -200,9 +200,18 @@ spring:
- `TIDB_USER`: `"root"`
- `TIDB_PASSWORD`: `""`

### 数据管理:`@Repository`
### 数据管理

Spring Data JPA 通过 `@Entity` 注册数据实体,并绑定数据库的表。

```java
@Entity
@Table(name = "player_jpa")
public class PlayerBean {
}
```

Spring Data JPA 通过 `@Repository` 接口来管理数据。你需要继承 `JpaRepository` 接口,以使用其提供的增删改查函数
`PlayerRepository` 通过继承 `JpaRepository` 接口,由 `JpaRepositoryFactoryBean` 为其自动注册对应的 Repository Bean。同时,`JpaRepository` 接口的默认实现类 `SimpleJpaRepository` 提供了增删改查函数的具体实现

```java
@Repository
Expand Down

0 comments on commit d0766c1

Please sign in to comment.