Java/Spring Boot

[Spring Boot] application.properties 설정

크리스피코드 2023. 3. 28. 00:08

0. application.properties

 

server.port=80
server.servlet.context-path=/

spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mariadb://127.0.0.1:3306/springboot
spring.datasource.username=root
spring.datasource.password=java

spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=ture

 

server.port 포트번호 설정
server.servlet.context-path Context-Path 설정
서버의 기초 경로가 된다.
예) context-path=/test
-> http://localhost/test

 

spring.datasource.driver-class-name 사용할 JDBC 드라이버
spring.datasource.url 사용할 DB의 URL
spring.datasource.username DB의 사용자명
spring.datasource.password DB 사용자의 비밀번호

 

spring.jpa.hibernate.ddl-auto 실행 시 테이블에 대한 설정
create: 실행 시 기존 테이블 삭제 후 재생성
create-drop: create와 동일하나 종료 시에 테이블 삭제
update: 변경된 부분만 반영
validate: 엔티티와 테이블이 제대로 매핑되었는지 확인
none: 없음
spring.jpa.show-sql DB 작업 수행 시 SQL문 표시
spring.jpa.properties.hibernate.format_sql 출력된 SQL문을 예쁘게 개행해서 표시할지 여부
false일 경우 한 줄로 보기 불편하게 나오지만
true일 경우 개행과 들여쓰기를 사용해 보기 편하게 출력된다.