Jin's Dev Story

[SpringBoot] 환경 설정 본문

Web & Android/SpringBoot

[SpringBoot] 환경 설정

woojin._. 2023. 10. 15. 09:49

자동 갱

 

1. 의존성 추가 - 추후 필요한 건 추가하면서 진행

  • Spring Boot DevTools
  • Lombok
  • Spring Data JPA
  • MySQL Driver
  • Thymeleaf
  • Spring Web

추가 설정

  • File/Setting/Build, Exe../Build Tools/Gradle/Gradle JVM : 17로 설정
  • Project Structure/Project/SDK - 17, Language level -17 or default
  • Project Structure/SDKs/17
  • File/Setting/Editor/File Encodings/UTF-8

2. DB 환경 설정 - application.properties 설정

  • 애플리케이션 포트 설정
    • server.port = 8000
  • MySQL 연결 설정
    • 사용할 DB 드라이버 설정
      • spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    • jdbc 설정
      • spring.datasource.url=jdbc:mysql://localhost:3306/shop?serverTimezone=UTC
    • DB 아이디
      • spring.datasource.username=root
    • DB 비밀번호
      • spring.datasource.password=1234

설정 후 DBeaver에서 데이터베이스를 shop으로 생성

  • JPA 설정
    • 쿼리 보이게 할 건지 설정 여부
      • spring.jpa.properties.hibernate.show_sql=true
    • 콘솔창에 출력되는 쿼리를 가독성 좋게 포맷팅
      • spring.jpa.properties.hibernate.format_sql=true
      • spring.jpa.hibernate.ddl-auto=update
    • 데이터베이스 언어 설정
      • spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
    • 쿼리에 물음표로 줄력되는 바인드 파라미터 출력
      • logging.level.org.hibernate.type.descriptor.sql=trace

 

'Web & Android > SpringBoot' 카테고리의 다른 글

[SpringBoot] 한글 변환(\u~)  (0) 2023.10.14
[SpringBoot] 에러 처리  (0) 2023.10.14
[SpringBoot] @Annotation  (1) 2023.10.14
[SpringBoot] 페이징 처리  (0) 2023.10.14
[SpringBoot] ResponseEntity  (0) 2023.10.14