Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource

Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.的解决办法
在这里插入图片描述
当我们启动启动类的时候,会报这个错误,说你没有配置数据库内容
spring boot 会默认加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration这个类,
而DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了dataSource bean,又因为项目(oss模块)中并没有关于dataSource相关的配置信息,所以当spring创建dataSource bean时因缺少相关的信息就会报错。
解决办法:
在@SpringBootApplication注解上加上exclude,解除自动加载DataSourceAutoConfiguration

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)

版权声明:本文为weixin_46426906原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。