개발 환경
- Spring Boot 2.6.6
- Java 11
- Gradle Project
- IntelliJ
- MySQL 8.0.20
의존성
- Spring Web
- JPA
- Lombok
- Spring Security //나중에 로그인, 회원가입 개발을 위해 사용
연동 순서
- MySQL Workbench 설치
- MySQL 권한 부여
- build.gradle 수정
- application.properties 수정
연동하는 법
1. MySQL Workbench 설치해서 비밀번호, 포트번호 설정
- time_zone 설정(에러 발생할 수도 있음)
time_zone 설정 및 'Asia/Seoul' 오류 해결법
2. MySQL 권한 부여
- 모든 DB, 테이블 관리 권한 부여
mysql> grant all privileges on *.* to 계정ID@localhost idnetified by '비밀번호';
- 권한 부여 내용 메모리에 반영하기
mysql> flush privileges;
- 권한이 잘 부여되었는지 확인
mysql> show grants for 계정ID@localhost;
3. spring 프로젝트 생성 후 IntelliJ에서 Open
4. build.gradle 수정
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'mysql:mysql-connector-java'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
5. application.properties 수정
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/데이터베이스명?serverTimezone=Asia/Seoul&characterEncoding=UTF-8
spring.datasource.username=아이디
spring.datasource.password=비밀번호
#JPA settings
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=none
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
반응형
'Spring & Spring Boot' 카테고리의 다른 글
Java 정리 - Spring (계속 추가) (0) | 2023.06.29 |
---|---|
Spring(Legacy) 초기 설정 - STS.exe (0) | 2023.06.29 |
MVC(Model, View, Controller) 개념 (0) | 2023.06.29 |
DI(Dependency Injection) 개념 (0) | 2023.06.29 |
Spring(Legacy) 개념 (0) | 2023.06.29 |