IDEA引入dao接口,Could not autowire. No beans of 'UserMapper' type found

Problem Description

I have been using Eclipse for a period of time for development, and I heard the industry's evaluation of IDEA is quite high, so I want to use IDEA to build a framework and develop it, but this thing is not as friendly as I thought, originally a simple framework is easy to use It can be built, but it has not been completed for a long time, and the main time is wasted on the way of filling the pits, and entering the topic: when using MyBatis, the dao interface (@Resource or @Auterwired) is introduced in ServiceImpl through SpringMVC annotations. On the variable of the dao interface (it seems to be changed to mapper in IDEA, but the essence is the same), an exception like the title is thrown. I have found a lot of solutions on the
write picture description here
Internet , but with little success - some people use ignore alarm configuration, mine The project is not successful; some people recommend using @Autowired(required = false) this way, ignoring the bean creation of this dao, my project can be started, but I can't configure such an annotation for every dao. ?
There are many similar solutions, but I want to say that none of the above methods can really solve the problem in essence

Cause Analysis

In fact, this is where IDEA is better than Eclipse. Don't blame IDEA, it's just more strict than Eclipse's verification, so it will cause similar errors, such as tags that can be self-enclosed in the configuration file. In the form of a tag pair, he throws a warning. Well, having said so much, the most fundamental reason is that we lack a plug-in support for Mybatis Plugin.

solution

Open IDEA, File->Settings->Plugins, search for Mybatis Plugin, select the plugin as shown in the figure, don't choose other!
write picture description here
After the download is completed, this thing cannot be enabled directly, because it has to be charged. Since it is a program, you must know how to crack it. Paste the URL: MyBatis Plugin
After learning to use the crack, start IDEA again, and the problem will no longer exist. There is, and this is the way to fundamentally solve the problem.
write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325604151&siteId=291194637