最近在远程调用过程中出现了:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
但是实际上我并没有做数据库相关的任何操作,出现此错误导致项目无法启动
检查原因:
可能是在导入依赖的时候导入的关于数据库的依赖,由于springboot的自动配置原理导致的错误!
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.14.Final</version>
<scope>compile</scope>
</dependency>
解决办法:
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@EnableDiscoveryClient
@EnableFeignClients
public class SearchApp {
public static void main(String[] args) {
SpringApplication.run(SearchApp.class,args);
}
}
在启动类上的@springbootApplication中加入exclude = DataSourceAutoConfiguration.class,解除自动加载DataSourceAutoConfiguration,即可解决此问题。