🛠️ 開発・MCP コミュニティ
java-springboot
Get best practices for developing applications with Spring Boot.
⚡ おすすめ: コマンド1行でインストール(60秒)
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o java-springboot.zip https://jpskill.com/download/19158.zip && unzip -o java-springboot.zip && rm java-springboot.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/19158.zip -OutFile "$d\java-springboot.zip"; Expand-Archive "$d\java-springboot.zip" -DestinationPath $d -Force; ri "$d\java-springboot.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
java-springboot.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
java-springbootフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Spring Boot のベストプラクティス
確立されたベストプラクティスに従い、高品質な Spring Boot アプリケーションを作成するお手伝いをします。
プロジェクトのセットアップと構造
- ビルドツール: 依存関係管理には Maven (
pom.xml) または Gradle (build.gradle) を使用します。 - スターター: 依存関係管理を簡素化するために、Spring Boot スターター (例:
spring-boot-starter-web、spring-boot-starter-data-jpa) を使用します。 - パッケージ構造: コードはレイヤー別 (例:
com.example.app.controller、com.example.app.service) ではなく、機能/ドメイン別 (例:com.example.app.order、com.example.app.user) に整理します。
依存性注入とコンポーネント
- コンストラクタインジェクション: 必須の依存関係には常にコンストラクタベースのインジェクションを使用します。これにより、コンポーネントのテストが容易になり、依存関係が明示的になります。
- イミュータビリティ: 依存関係フィールドは
private finalで宣言します。 - コンポーネントのステレオタイプ:
@Component、@Service、@Repository、および@Controller/@RestControllerアノテーションを適切に使用して、Bean を定義します。
設定
- 外部化された設定: 設定には
application.yml(またはapplication.properties) を使用します。YAML は、その読みやすさと階層構造からしばしば好まれます。 - 型安全なプロパティ:
@ConfigurationPropertiesを使用して、設定を厳密に型付けされた Java オブジェクトにバインドします。 - プロファイル: Spring Profiles (
application-dev.yml、application-prod.yml) を使用して、環境固有の設定を管理します。 - シークレット管理: シークレットをハードコードしないでください。環境変数、または HashiCorp Vault や AWS Secrets Manager のような専用のシークレット管理ツールを使用します。
Web レイヤー (コントローラ)
- RESTful API: 明確で一貫性のある RESTful エンドポイントを設計します。
- DTO (Data Transfer Objects): API レイヤーでデータを公開および消費するために DTO を使用します。JPA エンティティをクライアントに直接公開しないでください。
- バリデーション: DTO にアノテーション (
@Valid、@NotNull、@Size) を付けて Java Bean Validation (JSR 380) を使用し、リクエストペイロードを検証します。 - エラーハンドリング:
@ControllerAdviceと@ExceptionHandlerを使用してグローバルな例外ハンドラを実装し、一貫性のあるエラーレスポンスを提供します。
サービスレイヤー
- ビジネスロジック: すべてのビジネスロジックを
@Serviceクラス内にカプセル化します。 - ステートレス性: サービスはステートレスであるべきです。
- トランザクション管理: サービスメソッドに
@Transactionalを使用して、データベーストランザクションを宣言的に管理します。必要に応じて最も粒度の高いレベルで適用します。
データレイヤー (リポジトリ)
- Spring Data JPA: 標準的なデータベース操作には、
JpaRepositoryまたはCrudRepositoryを拡張して Spring Data JPA リポジトリを使用します。 - カスタムクエリ: 複雑なクエリには、
@Queryまたは JPA Criteria API を使用します。 - プロジェクション: DTO プロジェクションを使用して、データベースから必要なデータのみをフェッチします。
ロギング
- SLF4J: ロギングには SLF4J API を使用します。
- ロガー宣言:
private static final Logger logger = LoggerFactory.getLogger(MyClass.class); - パラメータ化されたロギング: パフォーマンスを向上させるために、文字列連結ではなく、パラメータ化されたメッセージ (
logger.info("Processing user {}...", userId);) を使用します。
テスト
- 単体テスト: JUnit 5 と Mockito のようなモックフレームワークを使用して、サービスとコンポーネントの単体テストを作成します。
- 統合テスト: Spring アプリケーションコンテキストをロードする統合テストには
@SpringBootTestを使用します。 - テストスライス:
@WebMvcTest(コントローラ用) や@DataJpaTest(リポジトリ用) のようなテストスライスアノテーションを使用して、アプリケーションの特定の部分を分離してテストします。 - Testcontainers: 実際のデータベースやメッセージブローカーなどを使用した信頼性の高い統合テストには、Testcontainers の使用を検討してください。
セキュリティ
- Spring Security: 認証と認可には Spring Security を使用します。
- パスワードエンコーディング: パスワードは常に BCrypt のような強力なハッシュアルゴリズムを使用してエンコードします。
- 入力サニタイズ: Spring Data JPA またはパラメータ化されたクエリを使用して SQL インジェクションを防ぎます。出力を適切にエンコードしてクロスサイトスクリプティング (XSS) を防ぎます。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Spring Boot Best Practices
Your goal is to help me write high-quality Spring Boot applications by following established best practices.
Project Setup & Structure
- Build Tool: Use Maven (
pom.xml) or Gradle (build.gradle) for dependency management. - Starters: Use Spring Boot starters (e.g.,
spring-boot-starter-web,spring-boot-starter-data-jpa) to simplify dependency management. - Package Structure: Organize code by feature/domain (e.g.,
com.example.app.order,com.example.app.user) rather than by layer (e.g.,com.example.app.controller,com.example.app.service).
Dependency Injection & Components
- Constructor Injection: Always use constructor-based injection for required dependencies. This makes components easier to test and dependencies explicit.
- Immutability: Declare dependency fields as
private final. - Component Stereotypes: Use
@Component,@Service,@Repository, and@Controller/@RestControllerannotations appropriately to define beans.
Configuration
- Externalized Configuration: Use
application.yml(orapplication.properties) for configuration. YAML is often preferred for its readability and hierarchical structure. - Type-Safe Properties: Use
@ConfigurationPropertiesto bind configuration to strongly-typed Java objects. - Profiles: Use Spring Profiles (
application-dev.yml,application-prod.yml) to manage environment-specific configurations. - Secrets Management: Do not hardcode secrets. Use environment variables, or a dedicated secret management tool like HashiCorp Vault or AWS Secrets Manager.
Web Layer (Controllers)
- RESTful APIs: Design clear and consistent RESTful endpoints.
- DTOs (Data Transfer Objects): Use DTOs to expose and consume data in the API layer. Do not expose JPA entities directly to the client.
- Validation: Use Java Bean Validation (JSR 380) with annotations (
@Valid,@NotNull,@Size) on DTOs to validate request payloads. - Error Handling: Implement a global exception handler using
@ControllerAdviceand@ExceptionHandlerto provide consistent error responses.
Service Layer
- Business Logic: Encapsulate all business logic within
@Serviceclasses. - Statelessness: Services should be stateless.
- Transaction Management: Use
@Transactionalon service methods to manage database transactions declaratively. Apply it at the most granular level necessary.
Data Layer (Repositories)
- Spring Data JPA: Use Spring Data JPA repositories by extending
JpaRepositoryorCrudRepositoryfor standard database operations. - Custom Queries: For complex queries, use
@Queryor the JPA Criteria API. - Projections: Use DTO projections to fetch only the necessary data from the database.
Logging
- SLF4J: Use the SLF4J API for logging.
- Logger Declaration:
private static final Logger logger = LoggerFactory.getLogger(MyClass.class); - Parameterized Logging: Use parameterized messages (
logger.info("Processing user {}...", userId);) instead of string concatenation to improve performance.
Testing
- Unit Tests: Write unit tests for services and components using JUnit 5 and a mocking framework like Mockito.
- Integration Tests: Use
@SpringBootTestfor integration tests that load the Spring application context. - Test Slices: Use test slice annotations like
@WebMvcTest(for controllers) or@DataJpaTest(for repositories) to test specific parts of the application in isolation. - Testcontainers: Consider using Testcontainers for reliable integration tests with real databases, message brokers, etc.
Security
- Spring Security: Use Spring Security for authentication and authorization.
- Password Encoding: Always encode passwords using a strong hashing algorithm like BCrypt.
- Input Sanitization: Prevent SQL injection by using Spring Data JPA or parameterized queries. Prevent Cross-Site Scripting (XSS) by properly encoding output.