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

The solution is at the bottom (the above is my mental journey)

It’s weird that the project that was still running yesterday, just opened it today.

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



I changed it and pom.xmlfound it was useless, changed it back and re-run and reported an error,
and then added the following dependencies
(deleted other dependencies related to mybatis, and only retained this)

 <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>2.2.0</version>
</dependency>

可是还是不可以!!不可以!!
Error again:

Unsatisfied dependency expressed through field ***mapper

Then I tried this method again

忘了扫描,对于包的扫描有两种方法:
一种是在mapper中直接加入@mapper,但是每个mapper都需要加注解
另一种是在application中加入扫描路径
@MapperScan(basePackages = "com.***.mapper")

还是不行啊!!!

最后我终于解决了!!!!!!!!

My steps are:
1. Add @Mapper to each mapper interface

The other is to add the scan path @MapperScan(basePackages = "com.***.mapper") to
the application-I will report an error in this way

2. Add to the program entry function

@ComponentScan(basePackages = {
    
    "com.***.***.实体类文件夹"})

"com.***.***.***"Parameters: It is the folder location of the class that does these two things
1. It is the attribute class, which is usually defined in the model layer.
2. The general entity class corresponds to a data table, and the attributes correspond to the fields in the data table.

Guess you like

Origin blog.csdn.net/weixin_49035356/article/details/109800524