๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Trouble Shooting

[Spring Boot] - Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration'

by ์ฃผ๋ฐœ2 2021. 3. 7.
๋ฐ˜์‘ํ˜•

 ์•ˆ๋…•ํ•˜์„ธ์š”~ ์ด์ „์— ์šด์˜ํ•˜๋˜ ๋ธ”๋กœ๊ทธ ๋ฐ GitHub, ๊ณต๋ถ€ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•˜๋Š” Study-GitHub ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค!

 ๋„ค์ด๋ฒ„ ๋ธ”๋กœ๊ทธ

 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

 

 

 

 

์œ„ ์„ค์ •์„ ํ•˜๊ณ  ์Šคํ”„๋ง ๋ถ€ํŠธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋‹ค์‹œ ์‹คํ–‰ํ•˜๋ฉด ์ •์ƒ์ ์œผ๋กœ ๊ธฐ๋™์ด ๋ฉ๋‹ˆ๋‹ค ๐Ÿ˜

 

 

 

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€