解决方案在最下面(上面是我的心路历程)
很奇怪,昨天还在正常运行的项目,今天打开就这样了
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-11-19 09:06:20.917 ERROR 1444 --- [ 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).
我改了pom.xml
发现没用又改回去了 重新运行又报错
然后又加了下面依赖
(删掉了其他和mybatis有关的依赖,只保留了这个)
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
可是还是不可以!!不可以!!
又报错:
Unsatisfied dependency expressed through field ***mapper
然后 我又按照这个方法尝试
忘了扫描,对于包的扫描有两种方法:
一种是在mapper中直接加入@mapper,但是每个mapper都需要加注解
另一种是在application中加入扫描路径
@MapperScan(basePackages = "com.***.mapper")
还是不行啊!!!
最后我终于解决了!!!!!!!!
我的步骤是:
1,在每一个mapper接口加入@Mapper
另一种是在application中加入扫描路径@MapperScan(basePackages = “com.***.mapper”)
–这个方式我会报错
2,在程序入口函数上加入
@ComponentScan(basePackages = {
"com.***.***.实体类文件夹"})
"com.***.***.***"
参数:就是做这两件事情的类所在的文件夹位置
1 .就是属性类,通常定义在model层里面
2. 一般的实体类对应一个数据表,其中的属性对应数据表中的字段。