우선 mysql-connector
와 JPA
라이브러리를 추가한다.
<dependencies>
<!-- Mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
dependencies {
compile 'mysql:mysql-connector-java'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
}
추가한 라이브러리에 설정값을 부여한다.
# server
server.port=8080
# jpa common
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.generate-ddl=true
# jpa mysql
spring.jpa.database=mysql
spring.datasource.url=jdbc:mysql://localhost:3306/{database_name}?useUnicode=true&serverTimezone=Asia/Seoul
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username={sql_username}
spring.datasource.password={sql_password}
사용할 데이터베이스를 UTF-8 charset으로 추가한다.
mysql.server start
mysql -u root -p
CREATE DATABASE {database_name} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
서버가 정상적으로 실행된다.