关于idea中SpringBoot启动失败的坑
2024-09-01 04:05:04
很多时候你新建了Maven 或者SpringBoot 工程,激动的点了主启动类,你就发现了下面的错误
Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message:
Error creating bean with name 'servletEndpointRegistrar' defined in class path resource
[org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$
WebMvcServletEndpointManagementContextConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]:
Factory method 'servletEndpointRegistrar' threw exception;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'healthEndpoint' defined in class path resource
[org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]:
Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'healthContributorRegistry' defined in class path resource
[org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]:
Factory method 'healthContributorRegistry' threw exception;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthContributorAutoConfiguration':
Unsatisfied dependency expressed through constructor parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]:
Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException:
Failed to determine a suitable driver class
[ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
--- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException:
Unable to start embedded Tomcat
--- [ restartedMain] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-09-03 13:12:04.338 ERROR 24572 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter : ***************************
APPLICATION FAILED TO START
*************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
这里说的是啥意思呢,你没有数据库相关的链接,数据库相关的链接在哪里配置呢,就是在你的Resource文件目录下的properties 或者yml文件中
但是这里你可能会说,我**不用数据库,我干啥配这个b玩意,我想说这句话的时候,你已经点了很多遍的主启动都报这个错误,
今天你算来对了,我敢肯定80%的人都遇到过这个问题。但是不知道为啥,今天我给你分析一下昂:
①:在IDEA 中用SpringInitial 点点点生成的SpringBoot/cloud项目
②:跟视频操作,一顿操作后发现不能启动,
③:DonwLoad下的代码 复制进去的POM依赖
还有很多昂,不墨迹了说重点吧。
解决方法:
首先着重看自己的POM依赖(是自己的POM,不是父工程,也不是其他工程,是自己的)中有无以下依赖
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
经过鄙人的测试,就是第一个依赖捣的鬼,这就是为啥你加了这个依赖你不配置相关的mysql链接,Spring就给你报错的原因。
最后提醒:按需注入POM才是正道,老铁们,我做的对么?
最新文章
- node入门学习1
- mysql二进制文件操作语法(mysql binary log operate statements)
- Sonar规则学习笔记
- HDU 5382 莫比乌斯反演
- 在Discuz中增加创始人
- ICANN认证企业列表
- Matlab多个Figure图合成一个Fig
- Java数据结构之树和二叉树
- jquery返回顶部特效
- cadence16.6 中orcad导出网表时ERROR (ORCAP-5004)(win7 旗舰版32位)
- jQuery easyUI框架中经常出现的问题
- (转载)Android开发者必知的开发资源
- 在git bush中如何退出vim编辑器
- 多封装,少开放。强烈建议C++标准添加class之间的注入机制
- git使用三把斧
- OCP读书笔记(1) - Oracle核心概念和工具
- centos 6.2安装bind 9.8.2 master、slave与自动修改后更新
- U3d keyCode值对应的按键
- 设计模式-建造者模式(Builder)
- spring batch (二) 元数据表
热门文章
- linux条件测试操作(test)和if判断语句,while循环语句,break控制语句和for循环和case多分枝语句和select语句
- ACL2020 Contextual Embeddings When Are They Worth It 精读
- Flexible实现H5移动端适配小demo
- python基础语法和实战练习
- 详解GaussDB(for MySQL)服务:复制策略与可用性分析
- Redis教程——检视阅读
- 准确率、精确率、召回率、F1
- ZooKeeper Watcher 机制
- 同步博客到cnblogs平台
- day12 异常 模块 单例