APPLICATION FAILED TO START(主要是mybatils引入冲突,在pom.xml里解决冲突即可)

文章描述了一个SpringBoot应用在初始化时遇到的问题,具体是Bean的创建过程中因数据源配置不完整和mybatis-plus-extension版本冲突导致的异常。解决方案是检查并升级mybatis-plus-extension的版本至3.5.3.1以解决冲突。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentController' defined in file [D:\javaback\MyDemo\target\classes\com\example\mydemo\controller\StudentController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentServiceImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'studentMapper' defined in file [D:\javaback\MyDemo\target\classes\com\example\mydemo\mapper\StudentMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class
2023-07-20T10:19:05.372+08:00  INFO 43492 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-07-20T10:19:05.394+08:00  INFO 43492 --- [           main] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-07-20T10:19:05.415+08:00 ERROR 43492 --- [           main] 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).


进程已结束,退出代码1

解决方案:1选择pom.xml

2鼠标移动到打开的pom.xml点击右键选择maven 显示图

3ctrl+鼠标左键移动找到红线  可以看到引入冲突

4将 pom.xml mybatis-plus-extension版本从3.4.0升级到3.5.3.1解决冲突

<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>3.4.0</version>
</dependency>

<!-- <dependency>-->
<!-- <groupId>com.baomidou</groupId>-->
<!-- <artifactId>mybatis-plus-extension</artifactId>-->
<!-- <version>3.5.3.1</version>-->
<!-- </dependency>-->

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值