728x90
반응형
Spring Boot 기본 구조
your-project/
│
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── example/
│ │ │ └── yourproject/
│ │ │ ├── YourProjectApplication.java <-- 애플리케이션 시작점
│ │ │ ├── controller/ <-- REST API 컨트롤러들
│ │ │ ├── service/ <-- 비즈니스 로직
│ │ │ ├── repository/ <-- 데이터 접근 계층
│ │ │ └── model/ <-- 엔티티, DTO 등
│ │ └── resources/
│ │ ├── application.properties or application.yml <-- 설정 파일
│ │ ├── static/ <-- 정적 리소스 (HTML, CSS, JS 등)
│ │ ├── templates/ <-- 템플릿 파일 (Thymeleaf 등)
│ │ └── application-dev.properties <-- 환경별 설정 파일
│ └── test/
│ └── java/
│ └── com/
│ └── example/
│ └── yourproject/
│ └── YourProjectApplicationTests.java <-- 테스트 클래스
├── pom.xml or build.gradle <-- 빌드 설정 파일 (Maven 또는 Gradle)
└── .gitignore <-- Git ignore 파일
👀 Gradle 기본 설정
보통 MVNRepository 사이트에서 필요한 의존성 검색해서 가져오면 된다.
✔️ Spring Boot 기본 의존성
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web' // Spring Boot Starter Web
implementation "org.springframework.boot:spring-boot-starter-web-services"
implementation 'org.springframework.boot:spring-boot-starter-security' // Spring Security
implementation 'org.springframework.boot:spring-boot-starter-logging' // 로깅 (Logback 사용)
implementation 'org.springframework.boot:spring-boot-starter-actuator' // 액추에이터 (모니터링)
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' // Thymeleaf 템플릿 엔진
testImplementation 'org.springframework.boot:spring-boot-starter-test' // 테스트 라이브러리
}
✔️ 데이터베이스 의존성
implementation 'mysql:mysql-connector-java:8.0.33' // MySQL 연동
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' // Spring Boot Starter Data JPA
annotationProcessor 'org.projectlombok:lombok' // lombok
compileOnly 'org.projectlombok:lombok'
✔️ application.properties 기본 설정
# server
server.port=8080 #서버 포트 번호
server.error.include-stacktrace=never #에러 구문 설정 - 안해도 됨
#db -- 데이터 베이스 연결
spring.datasource.url=jdbc:mysql://localhost:3306/[데이터베이스명]
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=[사용자계정]
spring.datasource.password=[비밀번호]
#jpa -- JPA 설정
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.format_sql=true
728x90
반응형
'Spring' 카테고리의 다른 글
Spring, Entity 구조 정리 / JPA에서 자주 사용되는 어노테이션 (0) | 2025.03.17 |
---|---|
Spring, Entity와 DTO의 차이점 및 구조 파악 / 변환 방법 (0) | 2025.03.13 |
Spring Boot, Spring Security란? (0) | 2025.03.12 |
Spring Boot, Delete 메서드 구현 (@DeleteMapping) (0) | 2025.02.25 |
Spring Boot, Swagger란? (0) | 2025.02.25 |