preface

Recently in the project refactoring, in the architect’s suggestion, the project myBatis to myBatis -plus. Because MyBatis – Plus only makes enhancements without changes on the basis of MyBatis, the switching cost is very low. You only need to change jar and configuration content, and the original code does not need to be changed.

Because myBatis – Plus friendly support for MyBatis, we spent a little time to change myBatis to MyBatis – Plus, that transformation is not successful, first start to see not know. However, as soon as it started, the car overturned and reported the following error

com.baomidou.mybatisplus.core.MybatisConfiguration.getLanguageDriver(Ljava/lang/Class;) Lorg/apache/ibatis/scripting/LanguageDriver;Copy the code

The complete exception information is shown in the following figure

Thinking of the February

From the printed exception information, we know that getLanguageDriver () does not exist. Follow up the source code to find

com.baomidou.mybatisplus.core.MybatisConfiguration
Copy the code

Or the superclass of MybatisConfiguration

org.apache.ibatis.session.Configuration
Copy the code

To provide. From the exception information we can guess that getLanguageDriver is needed if the project is to start successfully, and the MybatisConfiguration that the project currently references and its Configuration are not available. From this we can infer that our project introduces a fake MybatisConfiguration or Configuration. It is further inferred that there should be multiple MybatisConfiguration or Configuration in our project. In human terms, there is a class conflict in our project, or more bluntly, a JAR conflict

The validation process

1. Multiple MybatisConfiguration exist in the project?

Hold down the shortcut key Ctrl+Shift+R

2. Multiple Configurations exist in the project?

Hold down the shortcut key Ctrl+Shift+R

3. Verify that the package conflicts

Use the Maven-Helper plug-in to view JAR conflicts

solution

Using the Maven-Helper plug-in, we can see that the project was indirectly introduced in version 3.4.4 of Mybatis because of the package delivery dependency. Therefore, we can upgrade the project that references myBatis 3.4.4 to introduce MyBatis 3.5.3

conclusion

This article appears the pit is quite common, use search engine should be able to find the answer. In addition to introducing how to solve this problem, this article mainly wants to introduce a way of solving problems, that is, hypothesis verification method. Because it is not always possible to find the answer from the search engine, we can then use the known information to argue and infer step by step. Finally, if you are interested in maven conflict resolution, check out my previous article on Maven dependency Conflicts and solutions