Error Message
#1
myspringframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' 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]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver at org.springframework.bea
#2
Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested except
이 글을 보시는 분들은 아마 95% 확률로
application.yml 또는 application.properties 설정은 제대로 해주셨을 것이다.
하지만, 실행 시(Run DemoApplication) Table 생성에 실패하였다면?
아래 글을 참고하도록 하자.
1. (Maven 프로젝트 일 경우) pom.xml 파일에 의존성 추가
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.6.10</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
2. application.properties 파일에 DB 및 JPA 관련 설정
server.port = 70
spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/shop?serverTimezone=UTC&characterEncoding=UTF-8
spring.datasource.username = test
spring.datasource.password = test
spring.jpa.properties.hibernate.show_sql = true
spring.jpa.properties.hibernate.format_sql = true
spring.jpa.hibernate.ddl-auto = create
spring.jpa.database-platform = org.hibernate.dialect.MySQL5InnoDBDialect
logging.level.org.hibernate.type.descriptor.sql = trace
3. (Intellij) 프로젝트 우클릭 > Maven > Reload project
'Back-end > Spring Boot' 카테고리의 다른 글
Spring Boot+JPA+H2 로 Test Code 실행 시 테이블 생성 안될 때 (0) | 2023.01.11 |
---|---|
[Eclipse+Spring+Maven] 웹 프로젝트 Import 후 환경 세팅(feat.tomcat server) (0) | 2023.01.11 |