build.gradle
plugins {
id 'org.springframework.boot' version '2.6.6'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'io.github.woowacourse'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.rest-assured:rest-assured:4.4.0'
runtimeOnly 'com.h2database:h2'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
}
test {
useJUnitPlatform()
}
⇒ dependencies
의 runtimeOnly
에 h2 데이터베이스가 추가되어있다.
application.properties
spring.datasource.initialization-mode=always
spring.datasource.url=jdbc:h2:~/test;MODE=MYSQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa
spring.h2.console.enabled=true
security.jwt.token.secret-key=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIiLCJuYW1lIjoiSm9obiBEb2UiLCJpYXQiOjE1MTYyMzkwMjJ9.ih1aovtQShabQ7l0cINw4k1fagApg3qLWiB8Kt59Lno
security.jwt.token.expire-length= 18000000
⇒ spring.datasource.url
이 h2 데이터베이스로 설정되어 있다.
build.gradle
plugins {
id 'org.springframework.boot' version '2.6.6'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'io.github.woowacourse'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.rest-assured:rest-assured:4.4.0'
runtimeOnly 'mysql:mysql-connector-java'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
}
test {
useJUnitPlatform()
}
⇒ dependencies
의 runtimeOnly
의 값을 mysql 로 변경하였다.
application.properties
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.0.227:3306/shopping_cart?characterEncoding=utf8&autoReconnect=true
spring.datasource.username=reakong
spring.datasource.password=1234
security.jwt.token.secret-key=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIiLCJuYW1lIjoiSm9obiBEb2UiLCJpYXQiOjE1MTYyMzkwMjJ9.ih1aovtQShabQ7l0cINw4k1fagApg3qLWiB8Kt59Lno
security.jwt.token.expire-length= 18000000
⇒ spring.datasource.driver-class-name
에 mysql 드라이버를 설정한다.
⇒ spring.datasource.url
에 실제 db 서버 private ip 로 접근하도록 설정한다.
⇒ 생성한 디비 계정을 등록한다.
private ip
등 외부에서 알면 안되는 민감한 정보가 있으므로 깃허브에는 업로그 하지 않도록 .gitignore
파일 설정 필요
웹 서버에 미리 업로드해두어 깃허브에서 프로젝트를 받아온 후 임의로 미리 셋팅해둔 설정 파일로 대체
scp -i key-yukong.pem build.gradle [email protected]:/home/ubuntu
scp -i key-yukong.pem application.properties [email protected]:/home/ubuntu