0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Spring Boot + Javaでユーザー管理APIを簡単に作ってみた(JPAなし)

Posted at

✅ 背景と目的

Spring Boot の練習として、JPAを使わずにメモリ上で動くユーザー管理APIを実装しました。
主に以下の目的で設計しています:

  • Java × Spring Boot の基本構造を理解
  • Controller / Service / Repository の責務を整理
  • CRUD API の一連の実装を体験

🧩 実装構成(JPAなし)

UserController.java ← APIの窓口
UserService.java ← ロジック(nullチェック、例外処理など)
UserRepository.java ← 仮想DB(Listで代用)
User.java ← エンティティ(@Entity未使用)


🛠 API仕様(REST設計)

メソッド エンドポイント 説明
GET /users 全ユーザー取得
GET /users/{id} 指定ユーザー取得
POST /users ユーザー新規追加
PUT /users/{id} ユーザー情報更新
DELETE /users/{id} ユーザー削除

💡 技術ポイント

  • List<User> を仮想DBとして利用(簡易的なCRUDを実現)
  • List.copyOf() でリストを不変化 → セキュリティを意識
  • Optional で null 安全な設計
  • サービス層での orElseThrow による明示的な例外処理

🔍 使用技術

  • Java 17
  • Spring Boot 3.x
  • Gradle
  • IntelliJ IDEA

📌 ソースコード

GitHubリポジトリ:
🔗 https://github.com/hyeon-marina/LikeLion-Backend-Assignments/tree/main/Assignments/Week02


🏷 タグ

SpringBoot #Java #RESTAPI #バックエンド #学習記録


✍️ 補足

次回はJPA + MySQL連携版にアップグレード予定です。
Qiitaでも差分を比較できるように投稿していきます!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?