포트폴리오 서비스(프로필 설정 및 DB 전환하기)

·2024년 3월 10일
0

Portfolio Backtest

목록 보기
24/31

DB 전환이 필요한 이유

  • H2 db의 경우 개발에서 유리하지만 실제 운용에서는 부족하다
  • MySQL로 전환을 하자

프로필 설정 하기

배포용과 개발용 application.properties을 따로 설정할 수 있다.

application-dev.properties

# DATABASE
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.url=jdbc:h2:~/local
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=

# JPA
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=update

# JPA print
#spring.jpa.properties.hibernate.format_sql=true
#spring.jpa.properties.hibernate.show_sql=true

# devtools
spring.devtools.livereload.enabled=true

h2 콘솔을 사용하였다.

application-prod.properties

# DATABASE
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/domino?characterEncoding=UTF-8&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=


# JPA
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true

# JPA print
#spring.jpa.properties.hibernate.format_sql=true
#spring.jpa.properties.hibernate.show_sql=true

mysql을 사용하였다.

application.properties

spring.profiles.active=dev

#API KEYS
spring.profiles.include=API-KEY

#DataPortal base URL
dataPortal.url=https://apis.data.go.kr/1160100/service/GetStockSecuritiesInfoService
profile
백엔드 개발자가 꿈인 컴공과

0개의 댓글

관련 채용 정보