Spring Project Error: Error creating bean with name [How to Solve]

This kind of mistake is always encountered when doing exercises recently

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘com.example.Demo2MybatisApplicationTests’: Unsatisfied dependency expressed through field ‘userDao’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.example.dao.UserDao’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

There is a long string of balabalabala at the beginning; There are many solutions on the Internet, and the problem I have is that I don’t add the annotation of package scanning

The @mapperscan (“interface path”) annotation is added to the spring startup class

Its function is to specify the package where the interface to become the implementation class is located, and then all interfaces under the package will generate corresponding implementation classes after compilation.

With this project, there will be no error that the bean is not found

Read More: