본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)40k · #7260

java-springboot

하는 일

이 가이드는 권장되는 모범 사례를 따라 Spring Boot 기술로 Java 애플리케이션을 만드는 데 도움을 줍니다. 초기 설정부터 테스트와 보안까지 다루어 코드의 품질을 높이도록 합니다.

사용하는 경우

  • ✓새 Spring Boot 프로젝트를 시작할 때.
  • ✓기존 Spring Boot 코드를 리팩터링할 때.
  • ✓Spring Boot 개발을 배울 때.

스킬 링크

https://github.com/github/awesome-copilot/blob/main/skills/java-springboot/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/java-springboot/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“Spring Boot 프로젝트의 폴더를 어떻게 정리해야 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI는 프로젝트 설정 방법, 깔끔하고 효율적인 코드 작성, 설정과 데이터 관리, Spring Boot 애플리케이션을 안전하고 테스트 가능하게 만드는 방법에 대한 조언을 제공합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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/@RestController annotations appropriately to define beans.

Configuration

  • Externalized Configuration: Use application.yml (or application.properties) for configuration. YAML is often preferred for its readability and hierarchical structure.
  • Type-Safe Properties: Use @ConfigurationProperties to 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 @ControllerAdvice and @ExceptionHandler to provide consistent error responses.

Service Layer

  • Business Logic: Encapsulate all business logic within @Service classes.
  • Statelessness: Services should be stateless.
  • Transaction Management: Use @Transactional on 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 JpaRepository or CrudRepository for standard database operations.
  • Custom Queries: For complex queries, use @Query or 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 @SpringBootTest for 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.
자주 묻는 질문

Spring Boot '스타터(starter)'란 무엇인가요?

웹이나 데이터 접근 같은 일반적인 기능을 프로젝트에 쉽게 추가하도록 돕는 패키지입니다.

왜 생성자 주입을 쓰나요?

코드를 테스트하기 쉽게 만들고, 구성 요소가 필요로 하는 의존성이 무엇인지 명확히 보여 주기 때문입니다.

DTO란 무엇인가요?

API 계층과 클라이언트 사이에서 데이터를 전달하는 데 쓰는 객체입니다. 내부 데이터베이스 세부 사항이 직접 노출되는 것을 막습니다.

상세 정보

작성자의 원본 설명

Get best practices for developing applications with Spring Boot.

repo: github/awesome-copilot

인기도

GitHub 스타
40k
순위
#7260
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬