Written on
·
6.5K
0
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2m2021-08-17 14:33:56.743[0;39m [31mERROR[0;39m [35m28676[0;39m [2m---[0;39m [2m[ restartedMain][0;39m [36mo.s.b.d.LoggingFailureAnalysisReporter [0;39m [2m:[0;39m
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:
Property: spring.datasource.driver-class-name
Value: com.mysql.cj.jdbc.Driver
Origin: class path resource [application.properties]:4:37
Reason: Failed to load driver class com.mysql.cj.jdbc.Driver in either of HikariConfig class loader or Thread context classloader
Action:
Update your application's configuration
위처럼 에러가뜹니다 ㅜ 깃허브 올려주신거보고 그대로 가져와서 실행했는데 ㅜ 에러가나네요 혹시 어떤문제인지 짐작이 가시는지 궁금합니다~!
Answer 1
0
제가 오늘 github에 올여놓은 master 소스로 해보았는데 잘되네요.
동일한 상황인데 안되는거라면..
pom.xml에 아래 디펜더시를 추가해주시구
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
application.properties 프로퍼티 내용을 아래로 변경
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url = jdbc:mariadb://localhost:3306/example
spring.datasource.username = example
spring.datasource.password = example
위 프로퍼티 정보는 로컬이나 db에 세팅한 정보로 입력하셔야 합니다.
만약 mysql 이라면 아래처럼 기재
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/example
그리고 기존에 만들었떤 DatabaseConfiguration.java 파일은 삭제
기존에 올렸던 방식은 java configuration을 통해서 datasource를 생성하는거였는데요.
위에 기재한 방식은
spring-boot-starter-jdbc를 활용해서 자동으로 datasource가 생성되는 방식으로 변경하는 방식인데요
한번해보시길 바랍니다.
제가 직접해보고 잘되는거 확인되고 답변드려요.