[에러]Failed to determine a suitable driver class

박지원·2024년 9월 16일
0

Failed to determine a suitable driver class

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/readmate?serverTimezone=Asia/Seoul

오류 원인

  • 데이터 소스 구성 실패 
    DB에 연결하려는데 필요한 정보가 없어서 생기는 초기에 발생하는 오류다. 
    또는 application.propertes 파일이나 application.yml 파일과 같은 설정 파일이 삭제되었거나 위치가 옮겨졌을 경우에도 발생된다.

출처: https://codingmomong.tistory.com/638 [주니어 개발자 모몽'-':티스토리]

시도 방법

  • application.yml 에 datasource 가 잘 작성되어있는지 확인 -> 그런 것 같음
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/readmate?serverTimezone=Asia/Seoul
  • build.gralde 확인

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
	implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
	implementation 'org.springframework.boot:spring-boot-starter-security'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	compileOnly 'org.projectlombok:lombok'
	runtimeOnly 'com.mysql:mysql-connector-j'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testImplementation 'org.springframework.security:spring-security-test'
	testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

	implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'

	//의존성 추가
	implementation 'org.springframework.boot:spring-boot-starter'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
	implementation 'io.jsonwebtoken:jjwt:0.9.1'
	implementation 'org.springframework.boot:spring-boot-starter-webflux'

	implementation 'javax.xml.bind:jaxb-api:2.3.1'
	implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.1'
  
  //Swagger
	implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'

}

해결 방안

  • 알고보니 yml 보내준 것을 잘못 복붙함...
  • yml 파일 제대로 했는지 항상 잘 확인하자

0개의 댓글