1. project 초기 세팅
File > New Project (maven, jar) > Spring Initializr > Next > 아래 이미지와 같은 화면
프로젝트에서 필요한 dependency 추가
Spring Boot DevTools
, Lombok
, Spring Web
, Thymeleaf
, Spring Security
, Spring Data JPA
, MariaDB Driver
등
Project type을 maven으로 선택했기 때문에 프로젝트 생성 후 dependency는 pom.xml 파일에서 확인 할 수 있음
📦 Board
├─ src
│ └─ main
│ ├─ java
│ │ └─ packagename
│ │ ├─ config
│ │ ├─ controller
│ │ ├─ domain
│ │ ├─ repository
│ │ ├─ service
│ │ ├─ enumate
│ │ └─ util
│ └─ resources
│ ├─ static
│ │ └─ bootstrap
│ ├─ templates
│ │ ├─ board
│ │ ├─ fragments
│ │ ├─ auth
│ │ └─ index.html
│ └─ application.yml
└─ pom.xml
config
설정 관련 코드 작성, Bean 추가를 위한 WebMvcConfig, SpringSecurity 설정
domain
Table 구조 정의, DTO 클래스를 가지고 있음
repository
JPA 처리를 담당함. 쉽게 말하면 데이터 조작을 위한 메소드 인터페이스를 가짐
util
문자열 처리를 위한 패키지, 자주 쓰는 URL과 같은 문자열을 선언해 놓음
static.bootstrap
bootstrap 파일(template)을 넣을 패키지
templates.fragments
view에서 공통으로 띄울 요소들을 가지고 있음 ex) sidebar, footer 등
server:
port: 8080
servlet:
context-path: /
encoding:
charset: UTF-8
session:
timeout: 480m
error:
whitelabel:
enabled: false
include-stacktrace: always
spring:
servlet:
multipart:
location: /fileName/
max-file-size: 50MB
max-request-size: 50MB
main:
web-application-type: servlet
datasource:
url: jdbc:mariadb://localhost/database_name
username: id
password: pw
driver-class-name: org.mariadb.jdbc.Driver
jpa:
databaseplatform: org.hibernate.dialect.MariaDB103Dialect
hibernate:
ddl-auto: update
naming:
physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
implicit-strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl
open-in-view: true
showsql: true
sql:
init:
mode: never
thymeleaf:
prefix: classpath:templates/
suffix: .html
cache: true
devtools:
livereload:
enabled: false
add-properties: false
restart:
enabled: false
web:
resources:
chain:
compressed: true
enabled: true
cache: true
application properties 참고한 사이트
https://runebook.dev/ko/docs/spring_boot/appendix-application-properties