SpringBoot 项目启动出错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedde

简介: SpringBoot 项目启动出错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedde

不废话,直接上解决方案:


在springboot的启动类@SpringBootApplication上做点改动,如下:


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


好了。


PS 这个错误出现的原因:


最根本就是,springboot项目启动,自动配置,去加载数据库源,去找相关配置项,找不到,所以它报错。


为什么会这样,也许是如下情况:


a. 你项目里面需要用到数据库,导入了相关的数据库jar包,但是忘记配置 这些数据库的相关项信息了,所以项目找不到,报错。。

b.你项目实际上是不需要用到数据库的,所以根本会回去做任何相关的数据库项配置,但是你还是导入了相关的数据库jar包,所以项目找不到,报错。

c.你项目里面需要用到数据库,也导入了相关的数据库jar包,也写了相关的数据库配置信息,但是就是报错。 那么就是你的配置文件加载不成功,所以项目找不到,报错。


所以最简单暴力的就是,使用上面方案的注解,exclude一下。  

相关文章
|
Java
SpringBoot启动报错:org.apache.catalina.LifecycleException: Protocol handler start failed
SpringBoot启动报错:org.apache.catalina.LifecycleException: Protocol handler start failed
221 0
|
7月前
|
JavaScript 前端开发 Java
Idea启动SpringBoot程序报错:Veb server failed to start. Port 8082 was already in use;端口冲突的原理与解决方案
本文解决了Idea启动SpringBoot程序报错:Veb server failed to start. Port 8082 was already in use的问题,并通过介绍端口的使用原理和操作系统的端口管理机制,可以更有效地解决端口冲突问题,并确保Web服务器能够顺利启动和运行。 只有锻炼思维才能可持续地解决问题,只有思维才是真正值得学习和分享的核心要素。如果这篇博客能给您带来一点帮助,麻烦您点个赞支持一下,还可以收藏起来以备不时之需,有疑问和错误欢迎在评论区指出~
|
Java 数据库 Spring
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
335 0
|
Java Maven Spring
SpringBoot 系列之 Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resource
这篇文章描述了在使用Maven构建Spring Boot项目时遇到的`maven-resources-plugin`插件版本问题导致的编译失败,并提供了通过修改插件版本至3.1.0来解决这个问题的方法。
SpringBoot 系列之 Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resource
springboot 集成 swagger 2.x 和 3.0 以及 Failed to start bean ‘documentationPluginsBootstrapper‘问题的解决
本文介绍了如何在Spring Boot项目中集成Swagger 2.x和3.0版本,并提供了解决Swagger在Spring Boot中启动失败问题“Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerEx”的方法,包括配置yml文件和Spring Boot版本的降级。
springboot 集成 swagger 2.x 和 3.0 以及 Failed to start bean ‘documentationPluginsBootstrapper‘问题的解决
|
XML Java 关系型数据库
Springboot启动时报错Property ‘mapperLocations‘ was not specified.
Springboot启动时报错Property ‘mapperLocations‘ was not specified.
660 2
|
Java 关系型数据库 MySQL
【已解决】SpringBoot 启动报错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no emb
【已解决】SpringBoot 启动报错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no emb
7151 1
|
监控 druid Java
Springboot用JUnit测试接口时报错Failed to determine a suitable driver class configure a DataSource: ‘url‘
Springboot用JUnit测试接口时报错Failed to determine a suitable driver class configure a DataSource: ‘url‘
427 0
|
Java Maven Spring
SpringBoot运行出现 Lookup method resolution failed; nested exception is java.lang.IllegalStateException
SpringBoot运行出现 Lookup method resolution failed; nested exception is java.lang.IllegalStateException
3170 0
|
前端开发 JavaScript
前端JS截取url上的参数
文章介绍了两种前端JS获取URL参数的方法:手动截取封装和使用URLSearchParams。
306 0