Spring Boot报错
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
一、情况一
报错
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2022-07-24 17:54:00.774 ERROR 12512 — [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
/***************************
APPLICATION FAILED TO START
/***************************
Description:
Field carMapper in com.sgz.service.CarServiceImpl required a bean of type ‘com.sgz.dao.CarMapper’ that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type ‘com.sgz.dao.CarMapper’ in your configuration.
截图
解决
在启动类上加上注解 @MapperScan(“com.sgz.dao”)
@SpringBootApplication
@MapperScan("com.sgz.dao") // 在启动类中加上这个注解即可
public class RunApp {
public static void main(String[] args) {
SpringApplication.run(RunApp.class);
}
}
二、情况二
报错
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2022-07-24 18:06:12.632 ERROR 18812 — [ 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).
截图
解决
方法一
pom.xml中mybatis依赖包版本过低,换成高版本的即可
方法二
- 将mybatis的依赖包注释掉
- 然后刷新maven配置
方法三
-
将mybatis的依赖包注释掉
-
clean命令清除整个工程
-
然后再刷新maven配置