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一下。  

相关文章
|
5月前
|
Java
SpringBoot启动报错:org.apache.catalina.LifecycleException: Protocol handler start failed
SpringBoot启动报错:org.apache.catalina.LifecycleException: Protocol handler start failed
91 0
|
3月前
|
存储 前端开发 Java
SpringBoot使用云端资源url下载文件的接口写法
在Spring Boot中实现从云端资源URL下载文件的功能可通过定义REST接口完成。示例代码展示了一个`FileDownloadController`,它包含使用`@GetMapping`注解的方法`downloadFile`,此方法接收URL参数,利用`RestTemplate`下载文件,并将文件字节数组封装为`ByteArrayResource`返回给客户端。此外,通过设置HTTP响应头,确保文件以附件形式下载。这种方法适用于从AWS S3或Google Cloud Storage等云服务下载文件。
389 7
|
1月前
|
Java Spring
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‘问题的解决
|
2月前
|
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
|
5月前
|
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
73 0
|
4月前
|
XML Java 关系型数据库
Springboot启动时报错Property ‘mapperLocations‘ was not specified.
Springboot启动时报错Property ‘mapperLocations‘ was not specified.
138 2
|
4月前
|
监控 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‘
91 0
|
4月前
|
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
277 0
|
1月前
|
前端开发 JavaScript
前端JS截取url上的参数
文章介绍了两种前端JS获取URL参数的方法:手动截取封装和使用URLSearchParams。
34 0
|
2月前
|
开发框架 前端开发 .NET
Asp.net Webapi 的 Post 方法不能把参数加到 URL 中?试试这样写
Asp.net Webapi 的 Post 方法不能把参数加到 URL 中?试试这样写