티스토리 뷰
dependencies
- Web
- JPA
- Lombok
- H2 Database (테스트용 DB)
- MySQL Driver (개발/배포용 DB)
build.gradle
plugins {
id 'org.springframework.boot' version '2.2.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
IntelliJ IDE
- application.properties -> application.yml 변경
- prod, dev, test 환경마다 커스텀 설정 작성 (주로 datasource 관련)
- test DB는 메모리 모드로 동작
main/resources/application.yml
server:
port: 8080
spring:
datasource:
url: jdbc:mysql://server:3306/prod_db?characterEncoding=UTF-8&serverTimezone=Asia/Seoul
username: root
password: password
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
ddl-auto: none
properties:
hibernate:
format_sql: true
data:
web:
pageable:
default-page-size: 10
logging:
level:
org.hibernate.SQL: debug
org.hibernate.type: trace
--- # dev
spring.profiles: dev
spring:
datasource:
url: jdbc:mysql://localhost:3306/dev_db?characterEncoding=UTF-8&serverTimezone=Asia/Seoul
test/resources/application.yml
spring.profiles: test
spring:
datasource:
url: jdbc:h2:mem:test
username: sa
password:
driver-class-name: org.h2.Driver
jpa:
hibernate:
dialect: org.hibernate.dialect.H2Dialect
ddl-auto: create-drop
properties:
hibernate:
show_sql: true
format_sql: true
logging:
level:
org.hibernate.SQL: debug
org.hibernate.type: trace
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 회고
- vueJS
- 수강후기
- ES6
- build
- docker
- Notion
- springboot
- Groovy
- maven
- 똥글
- javascript
- Spring boot
- gradle
- trouble-shooting
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
글 보관함