Spring/문제 해결 (Troubleshooting)

Caused by: java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.

가지코딩 2025. 5. 12. 14:27

전체 에러

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jdbcMappingContext' defined in class path resource [org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration$SpringBootJdbcConfiguration.class]: Unsatisfied dependency expressed through method 'jdbcMappingContext' parameter 1: Error creating bean with name 'jdbcCustomConversions' defined in class path resource [org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration$SpringBootJdbcConfiguration.class]: Failed to instantiate [org.springframework.data.jdbc.core.convert.JdbcCustomConversions]: Factory method 'jdbcCustomConversions' threw exception with message: Error creating bean with name 'jdbcDialect' defined in class path resource [org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration$SpringBootJdbcConfiguration.class]: Failed to instantiate [org.springframework.data.relational.core.dialect.Dialect]: Factory method 'jdbcDialect' threw exception with message: jdbcUrl is required with driverClassName.

 

에러 요약

jdbcUrl is required with driverClassName.


에러 상황

단일 DB 연결 → 다중 DB 연결 설정 변경 중, 위의 에러 발생

 

 

기존 단일 DB

spring.datasource.url=jdbc:mysql://localhost:3306/todo
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

 

변경 다중 DB (에러)

spring.datasource.todo.url=jdbc:mysql://localhost:3306/todo
spring.datasource.todo.username=root
spring.datasource.todo.password=1234
spring.datasource.todo.driver-class-name=com.mysql.cj.jdbc.Driver

spring.datasource.todo-v2.url=jdbc:mysql://localhost:3306/todoV2
spring.datasource.todo-v2.username=root
spring.datasource.todo-v2.password=1234
spring.datasource.todo-v2.driver-class-name=com.mysql.cj.jdbc.Driver

해결 방법

url → jdbc-url 로 변경

spring.datasource.todo.jdbc-url=jdbc:mysql://localhost:3306/todo

spring.datasource.todo.jdbc-url=jdbc:mysql://localhost:3306/todo
spring.datasource.todo.username=root
spring.datasource.todo.password=1234
spring.datasource.todo.driver-class-name=com.mysql.cj.jdbc.Driver

spring.datasource.todo-v2.jdbc-url=jdbc:mysql://localhost:3306/todoV2
spring.datasource.todo-v2.username=root
spring.datasource.todo-v2.password=1234
spring.datasource.todo-v2.driver-class-name=com.mysql.cj.jdbc.Driver