Command Palette

Search for a command to run...

Назад к скиллам
скилл № 81375

spring-boot-patterns

Use when the user asks about Spring Boot service layer and transaction boundaries, @Transactional, constructor injection, Spring AOP, Spring Security filter…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить spring-boot-patterns в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Spring Boot Patterns

Purpose

Implement production-grade Spring Boot patterns — dependency injection, aspect-oriented programming, data access, security, transaction management, and testing.

Architecture Decision Trees

Injection Strategy

Criterion Constructor Field (@Autowired) Setter
Immutability Yes (final fields) No No
Testability Instantiate directly Reflection required Easy override
Null safety Compiler-enforced Runtime NPE if missing Runtime NPE
Circular dependency Detected at startup Hidden Hidden
Constructor params All in one call Zero-arg constructor needed Mutable
Framework coupling None (pure Java) Spring annotation Spring annotation

Decision: Constructor injection always. Field injection only in tests (via @InjectMocks). Setter injection never.

Transaction Propagation

Propagation Behavior Use Case
REQUIRED (default) Join existing or create new Most service methods
REQUIRES_NEW Suspend existing, create new Audit logging, independent actions
NESTED Savepoint within existing Partial rollback within batch
MANDATORY Fail if no existing tx Internal service calls that need caller tx
NEVER Fail if existing tx Long-running reads, avoid connection hold
SUPPORTS Optional tx Read-only queries, optional transactional
NOT_SUPPORTED Suspend existing Background tasks, after-commit actions

Decision: REQUIRED for write operations. REQUIRES_NEW for audit/events. Read-only SUPPORTS.

Testing Slice Strategy

Annotation Scope What's Mocked What's Real
@SpringBootTest Full app Nothing (full context) Everything
@WebMvcTest Web layer only Service layer Controllers, filters
@DataJpaTest JPA only Nothing Repositories, entities
@JsonTest JSON only Nothing JSON serialization
@RestClientTest REST client Server RestTemplate/WebClient
@DataRedisTest Redis Nothing Redis repos

Decision: @WebMvcTest for controller tests. @DataJpaTest for repository tests. @SpringBootTest for integration/E2E only.

Agent Protocol

Trigger

User request includes: Spring Boot patterns, Spring design patterns, dependency injection Spring, AOP, Spring Data, Spring Security, transaction management, Spring Testing, @Transactional, @Autowired, TestContainers, WireMock, @DataJpaTest, @WebMvcTest.

Input Context

  • Spring Boot version (3.x preferred)
  • Data access (Spring Data JPA, JDBC, R2DBC)
  • Security (Spring Security, OAuth2, JWT)
  • Testing framework (JUnit 5, Mockito, TestContainers)
  • Architecture (package-by-feature, hexagonal)

Output Artifact

Pattern implementations with code examples, configuration snippets, testing strategies.

Response Format

Produce artifact directly. No preamble, no postamble, no explanations. No filler, no hedging, no transitions. Strip articles a/an/the where unambiguous. Compress output — why use many token when few do trick.

Completion Criteria

  • DI pattern with constructor injection and qualifiers
  • AOP aspect for logging/performance/timing
  • Repository pattern with Spring Data
  • Security chain with JWT or OAuth2
  • Transaction propagation and isolation configured
  • Test slices for unit, integration, and E2E

Max Response Length

4096 tokens

Workflow

Step 1: Constructor Injection Pattern

// CORRECT: Constructor injection with required dependencies
@Service
public class OrderService {
    private final OrderRepository orderRepository;
    private final InventoryClient inventoryClient;
    private final EventPublisher eventPublisher;

    public OrderService(
        OrderRepository orderRepository,
        @Qualifier("cachingClient") InventoryClient inventoryClient,
        EventPublisher eventPublisher
    ) {
        this.orderRepository = orderRepository;
        this.inventoryClient = inventoryClient;
        this.eventPublisher = eventPublisher;
    }
}

// WRONG: Field injection — never do this
@Service
public class OrderService {
    @Autowired private OrderRepository orderRepository;  // NO
    @Autowired private InventoryClient inventoryClient;  // NO
}

// WRONG: Setter injection — avoid
@Service
public class OrderService {
    private OrderRepository orderRepository;

    @Autowired  // NO — use constructor
    public void setOrderRepository(OrderRepository repo) {
        this.orderRepository = repo;
    }
}

Step 2: Interface Segregation for Dependencies

// Define narrow interfaces — one responsibility each
public interface OrderRepository {
    Optional<Order> findById(OrderId id);
    Page<Order> findByCustomerId(String customerId, Pageable pageable);
    Order save(Order order);
    void deleteById(OrderId id);
}

public interface InventoryClient {
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/spring-boot-data-access.md
  • references/spring-boot-deployment.md
  • references/spring-boot-observability.md
  • references/spring-boot-security.md
  • references/spring-patterns.md
  • references/spring-testing.md

FAQ

Что делает скилл spring-boot-patterns?

Use when the user asks about Spring Boot service layer and transaction boundaries, @Transactional, constructor injection, Spring AOP, Spring Security filter chain or @DataJpaTest/@WebMvcTest. Produces Spring Boot pattern code. Not for package layout (use spring-boot-architecture).

Как установить скилл spring-boot-patterns?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл spring-boot-patterns запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить spring-boot-patterns с