I can do it(Feat. DEV)

[Maven]There are test failures(feat. Failed to determine a suitable driver class) 에러 해결 방법 본문

개발자 모드/오류처리

[Maven]There are test failures(feat. Failed to determine a suitable driver class) 에러 해결 방법

까짓거 해보자 개발자 2023. 8. 28. 17:59
728x90

기존 진행하는 React 프로젝트에 back단으로 Spring Boot를 추가하려고

 

https://start.spring.io 사이트에서 아래와 같은 설정으로 프로젝트를 생성함.

출처사진
출처 : https://start.spring.io

 

생성된 프로젝트 zip파일을 풀고 기분 좋게 intelliJ에서 import를 시킴.😁

 

그리고 메이븐으로 mvn install 명령어를 실행시켰는데..?

 

에러코드
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project uis: There are test failures.

Please refer to D:\dev\uis\target\surefire-reports for the individual test results.
...

 

빌드 중 위와 같은 에러를 나에게 선물해 줌.

 

728x90

 

처음에는 버전문제인가? 해서 갓글에 검색해 보니

 

빌드 중에 난 게 아니라 테스트 중에 에러가 났고 해결방법은 아래 사이트를 보면 아시겠지만

 

pom.xml 파일 > 플러그인 설정에 

 

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
       <version>2.22.0</version>
    <configuration>
        <testFailureIgnore>true</testFailureIgnore>
    </configuration>
</plugin>

 

위 코드를 추가하여 테스트 중 에러가 나더라도 무시하고 지나가도록 설정하는 방법을 찾음.

 

하지만 필자 생각으론 근본적인 에러를 해결한 게 아니라,

 

테스트 실패를 무시한다는 게 영 찜찜해서 다른 에러를 찾아봄.

 

에러코드

 

에러난 커맨드 스크롤을 더 올려보니 

 

java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: 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 i nstantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested except ion is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdb c.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

 

이러한 에러가 더 있는 걸 발견!🤦‍♂️

 

대충 보니 jpa 관련 문제인 듯하지만 일단 갓글에 에러(ailed to determine a suitable driver class)를 검색🔎

 

이유는 프로젝트 생성 시 JPA, Mybatis Dependency를 추가했었는데 datasource를 설정해주지 않아서 에러가 난 것😅

 

바로 pom.xml 파일로 가서 mybatis 및 jpa 의존성을 주석처리하고 

 

주석처리사진
pom.xml 의존성 주석처리

 

mvn install 해보니 정상적으로 빌드 및 테스트가 됨!!👍

 

https://start.spring.io 사이트로 간편하게 프로젝트 생성하고 의존성 추가하는데

 

미리 막 이것저것 추가하면 안 되겠다는 것을 경험함 끝.🤗

 

 

📢참고 사이트

 

https://fors.tistory.com/386

 

스프링부트 springboot mvn build test error 에러 해결

관련 글의 stackoverflow 링크 https://stackoverflow.com/questions/13170860/failed-to-execute-goal-org-apache-maven-pluginsmaven-surefire-plugin2-10test 링크를 타고 들어가면 다양한 답변이 나온다. 그 중에서 몇가지를 소개한

fors.tistory.com

https://haenny.tistory.com/298

 

Failed to determine a suitable driver class 오류 해결

오류 로그 ********************************* 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

haenny.tistory.com

 

728x90