• ์๋ ํ์ธ์~ ์ด์ ์ ์ด์ํ๋ ๋ธ๋ก๊ทธ ๋ฐ GitHub, ๊ณต๋ถ ๋ด์ฉ์ ์ ๋ฆฌํ๋ Study-GitHub ๊ฐ ์์ต๋๋ค!
• ๐
Spring Boot์์ ์ด๊ธฐ ํ๋ก์ ํธ๋ฅผ ์์ฑํ ๋, Spring Data JPA๋ฅผ ์ฒดํฌํ๊ณ ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋๋ฐ,
์ฒ์ ์ ํ๋ฆฌ์ผ์ด์ ์ ์คํํ๋ ค ํ๋ ์๋์ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: org.springframework.beans.BeanInstantiationException: ... ์๋ต *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active). |
Reason ๋ถ๋ถ์ ํ์ธํด๋ณด๋, ์ ๋นํ driver class๋ฅผ ๊ฒฐ์ ํ์ง ๋ชปํ๋ค๊ณ ๋์ต๋๋ค.
๊ทธ๋ฆฌ๊ณ Action: ๋ถ๋ถ ์๋์์ ํํธ๋ฅผ ์ฃผ๊ณ ์์ต๋๋ค.
์ ๋ ์๋ฒ ๋๋ DB๊ฐ ์๋ MySQL์ ์ ์ฉํ ๊ฒ์ด๋ฏ๋ก MySQL ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ properties๋ฅผ ์ค์ ํด์ค๋๋ค.
pom.xml ์ถ๊ฐ
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
application.properties ์ถ๊ฐ
spring.datasource.url=jdbc:mysql://localhost:3306/DB๋ช
์์ฑ?useSSL=false&characterEncoding=UTF-8&serverTimezone=UTC
spring.datasource.username=DB ์ ์ ๋ช
spring.datasource.password=DB ์ ์ ์ ํจ์ค์๋
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# mysql ์ฌ์ฉ
spring.jpa.database=mysql
# ์ฝ์์ sql ์ถ๋ ฅ ์ฌ๋ถ
spring.jpa.show-sql=true
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
์ ์ค์ ์ ํ๊ณ ์คํ๋ง ๋ถํธ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ค์ ์คํํ๋ฉด ์ ์์ ์ผ๋ก ๊ธฐ๋์ด ๋ฉ๋๋ค ๐
๋๊ธ