spring-boot
Spring Bootは、Javaを使ったアプリケーション開発を簡単にするフレームワークで、REST APIやデータベース連携、セキュリティ、監視機能などを自動で設定し、すぐに使える状態にするSkill。
📜 元の英語説明(参考)
Spring Boot is a Java framework that simplifies building production-ready applications. It provides auto-configuration, embedded servers, and opinionated defaults for REST APIs, data access with JPA, security, and monitoring via Actuator.
🇯🇵 日本人クリエイター向け解説
Spring Bootは、Javaを使ったアプリケーション開発を簡単にするフレームワークで、REST APIやデータベース連携、セキュリティ、監視機能などを自動で設定し、すぐに使える状態にするSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o spring-boot.zip https://jpskill.com/download/15405.zip && unzip -o spring-boot.zip && rm spring-boot.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15405.zip -OutFile "$d\spring-boot.zip"; Expand-Archive "$d\spring-boot.zip" -DestinationPath $d -Force; ri "$d\spring-boot.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
spring-boot.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
spring-bootフォルダができる - 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を使用すると、スタンドアロンで本番環境に対応したSpringアプリケーションを簡単に作成できます。クラスパスの依存関係に基づいてコンポーネントを自動構成し、組み込みのTomcat/Jettyを提供します。
クイックスタート
# Spring Initializrでプロジェクトを生成
curl https://start.spring.io/starter.tgz \
-d dependencies=web,data-jpa,postgresql,security,actuator,validation \
-d javaVersion=17 -d type=maven-project \
-d groupId=com.example -d artifactId=myapp | tar xzf -
プロジェクト構造
# 標準的なSpring Boot Mavenプロジェクト
src/main/java/com/example/myapp/
├── MyappApplication.java # メインクラス
├── config/ # 設定クラス
├── controller/ # RESTコントローラ
├── service/ # ビジネスロジック
├── repository/ # データアクセス (JPA)
├── model/ # エンティティクラス
├── dto/ # データ転送オブジェクト
├── exception/ # 例外ハンドラ
└── security/ # セキュリティ設定
src/main/resources/
├── application.yml # 設定
└── db/migration/ # Flywayマイグレーション
エンティティとリポジトリ
// model/Article.java — JPAエンティティ
package com.example.myapp.model;
import jakarta.persistence.*;
import java.time.Instant;
@Entity
@Table(name = "articles")
public class Article {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, length = 200)
private String title;
@Column(columnDefinition = "TEXT")
private String body;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "author_id")
private User author;
@Column(updatable = false)
private Instant createdAt = Instant.now();
// 簡潔にするため、ゲッターとセッターは省略
}
// repository/ArticleRepository.java — Spring Data JPAリポジトリ
package com.example.myapp.repository;
import com.example.myapp.model.Article;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ArticleRepository extends JpaRepository<Article, Long> {
Page<Article> findByAuthorId(Long authorId, Pageable pageable);
boolean existsByTitle(String title);
}
RESTコントローラ
// controller/ArticleController.java — REST APIエンドポイント
package com.example.myapp.controller;
import com.example.myapp.dto.ArticleRequest;
import com.example.myapp.dto.ArticleResponse;
import com.example.myapp.service.ArticleService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/articles")
@RequiredArgsConstructor
public class ArticleController {
private final ArticleService articleService;
@GetMapping
public Page<ArticleResponse> list(Pageable pageable) {
return articleService.findAll(pageable);
}
@GetMapping("/{id}")
public ArticleResponse get(@PathVariable Long id) {
return articleService.findById(id);
}
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public ArticleResponse create(@Valid @RequestBody ArticleRequest request) {
return articleService.create(request);
}
@DeleteMapping("/{id}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable Long id) {
articleService.delete(id);
}
}
バリデーション付きのDTO
// dto/ArticleRequest.java — バリデーションされたリクエストDTO
package com.example.myapp.dto;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
public record ArticleRequest(
@NotBlank @Size(max = 200) String title,
@NotBlank String body
) {}
サービス層
// service/ArticleService.java — ビジネスロジック
package com.example.myapp.service;
import com.example.myapp.dto.*;
import com.example.myapp.model.Article;
import com.example.myapp.repository.ArticleRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
public class ArticleService {
private final ArticleRepository repo;
public Page<ArticleResponse> findAll(Pageable pageable) {
return repo.findAll(pageable).map(this::toResponse);
}
@Transactional
public ArticleResponse create(ArticleRequest req) {
Article article = new Article();
article.setTitle(req.title());
article.setBody(req.body());
return toResponse(repo.save(article));
}
private ArticleResponse toResponse(Article a) {
return new ArticleResponse(a.getId(), a.getTitle(), a.getCreatedAt());
}
}
グローバル例外ハンドラ
// exception/GlobalExceptionHandler.java — 集中型エラー処理
package com.example.myapp.exception;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.*;
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<ProblemDetail> handleNotFound(ResourceNotFoundException ex) {
ProblemDetail detail = ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, ex.getMessage());
return ResponseEntity.status(404).body(detail);
}
}
セキュリティ設定
// security/SecurityConfig.java — Spring Securityの設定
package com.example.myapp.security;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.secur 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Spring Boot
Spring Boot makes it easy to create stand-alone, production-grade Spring applications. It auto-configures components based on classpath dependencies and provides embedded Tomcat/Jetty.
Quick Start
# Generate project with Spring Initializr
curl https://start.spring.io/starter.tgz \
-d dependencies=web,data-jpa,postgresql,security,actuator,validation \
-d javaVersion=17 -d type=maven-project \
-d groupId=com.example -d artifactId=myapp | tar xzf -
Project Structure
# Standard Spring Boot Maven project
src/main/java/com/example/myapp/
├── MyappApplication.java # Main class
├── config/ # Configuration classes
├── controller/ # REST controllers
├── service/ # Business logic
├── repository/ # Data access (JPA)
├── model/ # Entity classes
├── dto/ # Data transfer objects
├── exception/ # Exception handlers
└── security/ # Security config
src/main/resources/
├── application.yml # Configuration
└── db/migration/ # Flyway migrations
Entity and Repository
// model/Article.java — JPA entity
package com.example.myapp.model;
import jakarta.persistence.*;
import java.time.Instant;
@Entity
@Table(name = "articles")
public class Article {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, length = 200)
private String title;
@Column(columnDefinition = "TEXT")
private String body;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "author_id")
private User author;
@Column(updatable = false)
private Instant createdAt = Instant.now();
// Getters and setters omitted for brevity
}
// repository/ArticleRepository.java — Spring Data JPA repository
package com.example.myapp.repository;
import com.example.myapp.model.Article;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ArticleRepository extends JpaRepository<Article, Long> {
Page<Article> findByAuthorId(Long authorId, Pageable pageable);
boolean existsByTitle(String title);
}
REST Controller
// controller/ArticleController.java — REST API endpoints
package com.example.myapp.controller;
import com.example.myapp.dto.ArticleRequest;
import com.example.myapp.dto.ArticleResponse;
import com.example.myapp.service.ArticleService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/articles")
@RequiredArgsConstructor
public class ArticleController {
private final ArticleService articleService;
@GetMapping
public Page<ArticleResponse> list(Pageable pageable) {
return articleService.findAll(pageable);
}
@GetMapping("/{id}")
public ArticleResponse get(@PathVariable Long id) {
return articleService.findById(id);
}
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public ArticleResponse create(@Valid @RequestBody ArticleRequest request) {
return articleService.create(request);
}
@DeleteMapping("/{id}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable Long id) {
articleService.delete(id);
}
}
DTOs with Validation
// dto/ArticleRequest.java — validated request DTO
package com.example.myapp.dto;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
public record ArticleRequest(
@NotBlank @Size(max = 200) String title,
@NotBlank String body
) {}
Service Layer
// service/ArticleService.java — business logic
package com.example.myapp.service;
import com.example.myapp.dto.*;
import com.example.myapp.model.Article;
import com.example.myapp.repository.ArticleRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
public class ArticleService {
private final ArticleRepository repo;
public Page<ArticleResponse> findAll(Pageable pageable) {
return repo.findAll(pageable).map(this::toResponse);
}
@Transactional
public ArticleResponse create(ArticleRequest req) {
Article article = new Article();
article.setTitle(req.title());
article.setBody(req.body());
return toResponse(repo.save(article));
}
private ArticleResponse toResponse(Article a) {
return new ArticleResponse(a.getId(), a.getTitle(), a.getCreatedAt());
}
}
Global Exception Handler
// exception/GlobalExceptionHandler.java — centralized error handling
package com.example.myapp.exception;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.*;
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<ProblemDetail> handleNotFound(ResourceNotFoundException ex) {
ProblemDetail detail = ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, ex.getMessage());
return ResponseEntity.status(404).body(detail);
}
}
Security Configuration
// security/SecurityConfig.java — Spring Security setup
package com.example.myapp.security;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf(c -> c.disable())
.authorizeHttpRequests(auth -> auth
.requestMatchers("/api/public/**", "/actuator/health").permitAll()
.anyRequest().authenticated()
)
.oauth2ResourceServer(oauth -> oauth.jwt(jwt -> {}));
return http.build();
}
}
Configuration
# application.yml — application configuration
spring:
datasource:
url: jdbc:postgresql://localhost:5432/mydb
username: ${DB_USER:postgres}
password: ${DB_PASSWORD:}
jpa:
hibernate.ddl-auto: validate
open-in-view: false
management:
endpoints.web.exposure.include: health,info,metrics,prometheus
endpoint.health.show-details: when-authorized
server:
port: 8080
Testing
// controller/ArticleControllerTest.java — integration test
package com.example.myapp.controller;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest
@AutoConfigureMockMvc
class ArticleControllerTest {
@Autowired MockMvc mvc;
@Test
void listArticles() throws Exception {
mvc.perform(get("/api/articles")).andExpect(status().isOk());
}
}
Key Patterns
- Use constructor injection (Lombok
@RequiredArgsConstructor) over field injection - Use Java records for DTOs — immutable, concise
- Set
spring.jpa.open-in-view: falseto avoid lazy loading issues in controllers - Use
@Transactionalon service methods, not controllers - Use Spring Profiles (
application-dev.yml,application-prod.yml) for env-specific config - Use Flyway or Liquibase for migrations — never
ddl-auto: updatein production