WEB BE Repo/JAVA
자바 패키지 네이밍 컨벤션
조금씩 차근차근
2025. 4. 28. 01:27
일반적으로 패키지 네이밍 시 사용되는 용어들의 종류와 그 의미이다.
토큰 | 보통 포함되는 위치 | 의미/용도(관례) |
config | 최상위 또는 layer | 스프링 설정 클래스들 (Java Config, 빈 정의, 프로퍼티 등) |
domain | Bounded Context 안 | 도메인 모델: 엔티티, 밸류, 애그리거트, 도메인 서비스 |
entity | domain 하위 또는 별도 | JPA @ Entity 전용 클래스 |
dto / model | domain 옆 | 계층 간 데이터 전달용 객체 (DTO/VO) |
repository | infrastructure 또는 domain | 영속성 인터페이스, Spring Data 리포지토리 |
persistence / infra(structure) | root layer | DB·메시징·외부 API 등 인프라 어댑터 |
service | application layer | 비즈니스 규칙·유스케이스 구현 |
usecase | service 대안 | “인터랙터”·“유스케이스” 객체를 명시할 때 |
controller | web | Spring MVC @Controller |
rest / api / web | presentation | REST API 컨트롤러 또는 외부 API 래퍼 |
adapter / gateway | infra | 외부 시스템 연결 (hexagonal/clean architecture) |
security | cross-cutting | 인증·인가 설정 및 컴포넌트 |
exception / error | 어디든 | 커스텀 예외 계층 |
util / common / shared | 어디든 | 순수 유틸리티·공통 코드 |
constants | common | 상수 집합 (enum, static final 등) |
scheduler / batch | job layer | 배치 작업, Quartz/Spring Batch 잡 |
test / mock / stub | src/test/java 쪽 | 테스트 전용 구현체 |