项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde(代码片段

Posted 晚风

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde(代码片段相关的知识,希望对你有一定的参考价值。

原因是Spring Boot自动配置的时候发现没有配置数据库

1、SpringBootApplication项目解决办法:

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class BdservoApplication {
 
	public static void main(String[] args) {
		SpringApplication.run(BdservoApplication.class, args);
	}
}

2、SpringCloudApplication项目解决方案

# spring配置
spring:
  #排除DruidDataSourceAutoConfigure
  autoconfigure:
    exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure

  

以上是关于项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde(代码片段的主要内容,如果未能解决你的问题,请参考以下文章