joe 发表于 2022-5-6 17:20:58

Error creating bean with name 'dataSource' defined in class path resource

今天在做实验时,出现:Error creating bean with name ‘dataSource‘ defined in class path resource这样的错误提示。网上有人说注释掉:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
但我的项目中还是出现其它错误,可能是pom dependency没有仔细搞好,算了,这种这弄了。
网上还有人说:
在SpringbootApplication.class里添加注解
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
但其实这种说法与我的版本是不匹配的,在我的版本中应该是:
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
当然,实验到此时出错,是因为我还没有真正用到mysql,我相信真正用到mysql之后错误就会消失。
页: [1]
查看完整版本: Error creating bean with name 'dataSource' defined in class path resource