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>-->