Failed to determine a suitable driver class && Unsatisfied dependency expressed through field dao

解决方案在最下面(上面是我的心路历程)

很奇怪,昨天还在正常运行的项目,今天打开就这样了

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. 一般的实体类对应一个数据表,其中的属性对应数据表中的字段。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值