Skip to content

Commit 1274440

Browse files
authored
Merge pull request #406 from luxun1910/master
创建了日语版本 + 细致的修正
2 parents ea229d3 + c288051 commit 1274440

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+13092
-2
lines changed

astro.config.mjs

+33
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default defineConfig({
99
integrations: [
1010
starlight({
1111
title: "MyBatis-Plus",
12+
defaultLocale: 'root',
1213
logo: {
1314
src: "./src/assets/logo.svg",
1415
},
@@ -61,6 +62,14 @@ export default defineConfig({
6162
root: {
6263
label: "简体中文",
6364
lang: "zh-CN",
65+
},
66+
en: {
67+
label: 'English',
68+
lang: 'en',
69+
},
70+
ja: {
71+
label: '日本語',
72+
lang: 'ja',
6473
}
6574
},
6675
editLink: {
@@ -73,34 +82,58 @@ export default defineConfig({
7382
sidebar: [
7483
{
7584
label: "简介",
85+
translations: {
86+
en: 'Introduction',
87+
ja: 'イントロダクション'
88+
},
7689
link: "/introduce",
7790
},
7891
{
7992
label: "从这里开始",
93+
translations: {
94+
en: 'Start Here',
95+
ja: 'ここから始める'
96+
},
8097
autogenerate: {
8198
directory: "getting-started",
8299
},
83100
},
84101
{
85102
label: "指南",
103+
translations: {
104+
en: 'Guides',
105+
ja: 'ガイドライン'
106+
},
86107
autogenerate: {
87108
directory: "guides",
88109
},
89110
},
90111
{
91112
label: "插件",
113+
translations: {
114+
en: 'Plugins',
115+
ja: 'プラグイン'
116+
},
92117
autogenerate: {
93118
directory: "plugins",
94119
},
95120
},
96121
{
97122
label: "参考",
123+
translations: {
124+
en: 'Reference',
125+
ja: 'リファレンス'
126+
},
98127
autogenerate: {
99128
directory: "reference",
100129
},
101130
},
102131
{
103132
label: "资源",
133+
translations: {
134+
en: 'Resources',
135+
ja: 'リソース'
136+
},
104137
autogenerate: {
105138
directory: "resources",
106139
},

src/content/docs/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ hero:
99
title: MyBatis-Plus
1010
tagline: MyBatis 最佳搭档,只做增强不做改变,为简化开发、提高效率而生。
1111
image:
12-
file: ../../assets/logo.svg
12+
file: '@/assets/logo.svg'
1313
actions:
1414
- text: 快速开始
1515
link: /introduce

src/content/docs/ja/404.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: '404'
3+
template: splash
4+
editUrl: false
5+
hero:
6+
title: '404'
7+
tagline: ページが見つかりませんでした。URLを確認するか、検索ボックスをお試しください。
8+
---
9+
10+
MyBatis-Plus のドキュメントはリニューアルされ、Astro を使用して構築されています。そのため、旧リンクとの互換性がない場合があります。もし旧リンクでアクセスしてページが見つからない場合は、新しいドキュメントを改めてご覧いただき、新しいリンクを保存してください。
11+
12+
<br/>
13+
14+
<script>
15+
setTimeout(() => {
16+
window.location.href = '/';
17+
}, 10000);
18+
</script>
19+
20+
<p>10秒後に自動でトップページへジャンプします。ジャンプしない場合は<a href="/">こちらをクリック</a>してください。</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: 設定
3+
sidebar:
4+
order: 3
5+
---
6+
7+
MyBatis-Plus は簡単に組み込むことができ、わずかな設定だけでその強力な機能をすぐに利用できます!
8+
9+
:::tip
10+
設定について説明する前に、MyBatis-Plus がインストールされていることを確認してください。まだインストールされていない場合は、[インストール](/ja/getting-started/install) の章をご覧ください。
11+
:::
12+
13+
## Spring Boot プロジェクト
14+
15+
- MapperScan アノテーションを設定します
16+
17+
```java {2}
18+
@SpringBootApplication
19+
@MapperScan("com.baomidou.mybatisplus.samples.quickstart.mapper")
20+
public class Application {
21+
22+
public static void main(String[] args) {
23+
SpringApplication.run(Application.class, args);
24+
}
25+
26+
}
27+
```
28+
29+
## Spring プロジェクト
30+
31+
- MapperScan を設定します
32+
33+
```xml {2}
34+
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
35+
<property name="basePackage" value="com.baomidou.mybatisplus.samples.quickstart.mapper"/>
36+
</bean>
37+
```
38+
39+
- SqlSessionFactory を MyBatis-Plus の SqlSessionFactory に切り替える
40+
41+
```xml {1}
42+
<bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
43+
<property name="dataSource" ref="dataSource"/>
44+
</bean>
45+
```
46+
47+
通常、一般的でシンプルなプロジェクトであれば、上記の設定だけで MyBatis-Plus を問題なく利用できます。具体的には、以下のプロジェクトを参考にしてください:[Spring Boot 快速启动示例](https://github.com/baomidou/mybatis-plus-samples/tree/master/mybatis-plus-sample-quickstart)[Spring MVC 快速启动示例](https://github.com/baomidou/mybatis-plus-samples/tree/master/mybatis-plus-sample-quickstart-springmvc)
48+
49+
また、MyBatis-Plus では、さまざまな複雑さのプロジェクトに対応できるよう、豊富なカスタマイズ設定を提供しています。プロジェクトの要件に応じて、必要な設定を柔軟に利用できます。詳しい設定内容については、[リファレンス](/ja/reference/)をご参照ください。
50+
51+
複雑なテーブル構造に対応するため、特別な要件に応じた豊富なフィールドアノテーションも提供しています。詳細については、[アノテーション](/ja/reference/annotation/)をご参照ください。
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
---
2+
title: クイックスタート
3+
sidebar:
4+
order: 1
5+
---
6+
7+
import LastedDependency from '@/components/LastedDependency.astro';
8+
9+
簡単なデモを通して、MyBatis-Plus の強力な機能を説明します。前提知識は以下の通りです:
10+
11+
- Java 開発環境と対応した IDE を所有している
12+
- Spring Bootを熟知している
13+
- Maven または Gradleを熟知している
14+
15+
---
16+
17+
1つの User テーブルがあり、以下のような構造となっています:
18+
19+
| id | name | age | email |
20+
|----|--------|-----|--------------------|
21+
| 1 | Jone | 18 | [email protected] |
22+
| 2 | Jack | 20 | [email protected] |
23+
| 3 | Tom | 28 | [email protected] |
24+
| 4 | Sandy | 21 | [email protected] |
25+
| 5 | Billie | 24 | [email protected] |
26+
27+
対応するデータベース Schema スクリプトは以下の通りです:
28+
29+
```sql
30+
<!-- schema-h2.sql -->
31+
32+
DROP TABLE IF EXISTS `user`;
33+
34+
CREATE TABLE `user`
35+
(
36+
id BIGINT NOT NULL COMMENT '主键ID',
37+
name VARCHAR(30) NULL DEFAULT NULL COMMENT '姓名',
38+
age INT NULL DEFAULT NULL COMMENT '年龄',
39+
email VARCHAR(50) NULL DEFAULT NULL COMMENT '邮箱',
40+
PRIMARY KEY (id)
41+
);
42+
```
43+
44+
対応するデータベース Data スクリプトは以下の通りです:
45+
46+
```sql
47+
<!-- data-h2.sql -->
48+
49+
DELETE FROM `user`;
50+
51+
INSERT INTO `user` (id, name, age, email) VALUES
52+
(1, 'Jone', 18, '[email protected]'),
53+
(2, 'Jack', 20, '[email protected]'),
54+
(3, 'Tom', 28, '[email protected]'),
55+
(4, 'Sandy', 21, '[email protected]'),
56+
(5, 'Billie', 24, '[email protected]');
57+
```
58+
59+
---
60+
61+
:::tip[分かりますか?]
62+
ゼロから MyBatis-Plus を使ってこのテーブルの CRUD(作成・読み取り・更新・削除)を実現するには、どのような作業が必要でしょうか?
63+
:::
64+
65+
## プロジェクトの新規作成
66+
67+
空の Spring Boot プロジェクトを作成し、H2 データベースを導入して結合テストを行います。
68+
69+
:::tip
70+
[Spring Initializer](https://start.spring.io/#!type=maven-project&language=java&platformVersion=3.1.8&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=h2) をクリックすると、すぐに Spring Boot プロジェクトをセットアップできます
71+
:::
72+
73+
## 依存関係の追加
74+
75+
MyBatis-Plus Starter への依存関係を追加します
76+
77+
### Spring Boot2
78+
79+
<LastedDependency groupId="com.baomidou" artifactId="mybatis-plus-boot-starter" />
80+
81+
### Spring Boot3
82+
83+
<LastedDependency groupId="com.baomidou" artifactId="mybatis-plus-spring-boot3-starter" />
84+
85+
86+
## 設定
87+
88+
`application.yml` 設定ファイルに、H2 データベース関連の設定を追加します:
89+
90+
```yaml
91+
<!-- application.yml -->
92+
93+
# DataSource Config
94+
spring:
95+
datasource:
96+
driver-class-name: org.h2.Driver
97+
username: root
98+
password: test
99+
sql:
100+
init:
101+
schema-locations: classpath:db/schema-h2.sql
102+
data-locations: classpath:db/data-h2.sql
103+
```
104+
105+
上記の設定は、どの Spring Boot プロジェクトでも共通して使用されるデータベース接続情報です。もし MySQL など他のデータベースを使用している場合は、対応する設定内容を変更する必要があります。
106+
107+
Spring Boot の起動クラスに `@MapperScan` アノテーションを追加し、Mapper フォルダをスキャンします:
108+
109+
```java {2}
110+
<!-- Application.java -->
111+
112+
@SpringBootApplication
113+
@MapperScan("com.baomidou.mybatisplus.samples.quickstart.mapper")
114+
public class Application {
115+
116+
public static void main(String[] args) {
117+
SpringApplication.run(Application.class, args);
118+
}
119+
120+
}
121+
```
122+
123+
## コーディング
124+
125+
エンティティクラス `User.java` を作成します:
126+
127+
```java
128+
<!-- User.java -->
129+
130+
@Data
131+
@TableName("`user`")
132+
public class User {
133+
private Long id;
134+
private String name;
135+
private Integer age;
136+
private String email;
137+
}
138+
```
139+
140+
:::note
141+
上記の例では 、[Lombok](https://projectlombok.org/) を使用してコードを生成しています。この方法に慣れていなければ、Getter/Setterメソッドを手動で作成してください。
142+
:::
143+
144+
145+
Mapper インターフェース `UserMapper.java` を作成します:
146+
147+
```java
148+
public interface UserMapper extends BaseMapper<User> {
149+
150+
}
151+
```
152+
153+
## 使用開始
154+
155+
テストクラスを追加して、機能テストを行います:
156+
157+
```java
158+
@SpringBootTest
159+
public class SampleTest {
160+
161+
@Autowired
162+
private UserMapper userMapper;
163+
164+
@Test
165+
public void testSelect() {
166+
System.out.println(("----- selectAll method test ------"));
167+
List<User> userList = userMapper.selectList(null);
168+
Assert.isTrue(5 == userList.size(), "");
169+
userList.forEach(System.out::println);
170+
}
171+
172+
}
173+
```
174+
175+
:::tip
176+
UserMapper の `selectList()` メソッドのパラメータは、MyBatis-Plus に組み込まれている条件ラッパー `Wrapper` です。そのため、パラメータを指定しない場合は条件なしになります。
177+
:::
178+
179+
コンソール出力結果:
180+
181+
```txt
182+
User(id=1, name=Jone, age=18, [email protected])
183+
User(id=2, name=Jack, age=20, [email protected])
184+
User(id=3, name=Tom, age=28, [email protected])
185+
User(id=4, name=Sandy, age=21, [email protected])
186+
User(id=5, name=Billie, age=24, [email protected])
187+
```
188+
189+
:::note
190+
完全なコードサンプルは、以下のリンクをご覧ください:[Spring Boot 快速启动示例](https://github.com/baomidou/mybatis-plus-samples/tree/master/mybatis-plus-sample-quickstart) | [Spring MVC 快速启动示例](https://github.com/baomidou/mybatis-plus-samples/tree/master/mybatis-plus-sample-quickstart-springmvc)
191+
:::
192+
193+
## まとめ
194+
195+
以上の数ステップで、User テーブルの CRUD 機能を実装することができました。XML ファイルさえ書く必要はありません!
196+
197+
これらの手順から分かるように、MyBatis-Plus の導入はとても簡単で、starter 依存関係を追加し、簡単な設定を行うだけで使用できます。
198+
199+
しかし、MyBatis-Plus の強みはこれだけではありません。MyBatis-Plus のより強力な機能を詳しく知りたい方は、このまま読み進めてください!

0 commit comments

Comments
 (0)