pom.xml에 jdbc나 H2같은 DB에 대한 의존성을 주입할 경우 스프링 부트는 자동으로 DB에 연결하려고 시도한다.
그러나 만약 DB값을 입력하지 않아서 연결을 할 수 없는 경우
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded
datasource could be configured.
Reason: Failed to determine a suitable driver class
위와 같은 메세지를 볼 수 있다.
해결 방법으로는
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306{경로}/{데이터베이스 스키마}?serverTimezone=Asia/Seoul&useUniCode=yes&characterEncoding=UTF-8
username: {아이디}
password: {비밀번호}
@Configuration
public class Configuration {
@Bean
public DataSource datasource() {
return DataSourceBuilder.create()
.driverClassName("")
.url("")
.username("")
.password("")
.build();
}
}
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})