관리 메뉴

프로그래밍 삽질 중

[spring-boot]Spring Boot – Error creating bean with name ‘dataSource’ 오류 본문

과거 프로그래밍 자료들/컴퓨터설정&오류

[spring-boot]Spring Boot – Error creating bean with name ‘dataSource’ 오류

평부 2021. 7. 5. 22:20

※ 스프링 프로젝트 의존성 설정 후 작동 시 오류

※ 문제점을 찾다가 dataSource -> application.yml이 문제인가 해서 수정 -> 문제 해결 안 됨

※ 검색 후 참고 자료를 찾음 

https://vpkarmani.com/spring/spring-boot-error-creating-bean-with-name-datasource/

 

Spring Boot - Error creating bean with name 'dataSource' - Vijay Karmani

Error creating bean with name 'dataSource' defined in class path resource error. This article will help in finding out the reason and solution for the same.

vpkarmani.com

 

[오류 - 해결 전]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package example.demo;
 
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
 
@SpringBootApplication(scanBasePackages = {"example.demo"})
 
public class DemoApplication {
 
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
 
}
 
cs

 

[해결]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package example.demo;
 
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 
@SpringBootApplication(scanBasePackages = {"example.demo"})
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class }) //이 부분 
public class DemoApplication {
 
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
 
}
 
cs