발생 환경
- SpringBoot v3.2.3
- MySQL 8.1
문제점
application.properties
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
Cannot resolve class or package 'mysql' Cannot resolve class or package 'cj' Cannot resolve class or package 'jdbc' Cannot resolve class 'Driver'
gradle build 시
User Starting a Gradle Daemon, 3 stopped Daemons could not be reused, use --status for details > Task :compileJava FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileJava'. > Could not resolve all files for configuration ':compileClasspath'. > Could not find mysql:mysql-connector-java:8.1.0. Required by: project : * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 3s 2 actionable tasks: 2 executed
문제 탐색
build.gradle
implementation 'mysql:mysql-connector-java'
MySQL과 연결하기 위하여 build.gradle 파일에서 의존성을 추가하였지만, 이제 mysql:mysql-connector-java 의 네이밍이 변경됨.
해결
mysql:mysql-connector-java → com.mysql:mysql-connector-j 로 변경
참고문헌
https://luvstudy.tistory.com/221
https://blogs.oracle.com/mysql/post/mysql-connectorj-has-new-maven-coordinates
'Backend > Java' 카테고리의 다른 글
스프링 어노테이션 정리 (0) | 2023.04.20 |
---|