First look at the files generated after using mybatisX.
1. First install the mybatisX plugin in idea, search for the mybatisX plugin in file->setting->plugins, and restart idea.
2. Click Database on the right side of the idea editor, click "+" to link your database type, here I choose mysql.
Enter root, password: xxxx
输入url:jdbc:mysql://localhost:3306/emos?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
After that, it will automatically fill in: Database: emos
Click "Test Connection" to connect to the database. If you can't connect. You need to follow the prompts to install the mysql plugin.
3. After confirming, close, right-click "Refresh", and the data table will come out.
4. Right click on a data table, MybatisX-Generator appears
5. Analyze the meaning of the interface.
6. In the next step, select the template of mybatis-plus3, and check lombok, and the entity class generated by checking lombok will have lombok annotations.
7. Click "Finish" to complete, prompt
8. The effect picture is:
9. Open a class that is automatically generated, prompting the bug to explode.
程序包com.baomidou.mybatisplus.extension.service不存在
Just install dependencies in pom.xml
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1.tmp</version>
</dependency>
10. A bug is reported when starting the project
springboot available: expected at least 1 bean which qualifies as autowire candidate
It is because the default rules of Bean assembly in the SpringBoot project are scanned from top to bottom according to the package location where the Application class is located.
So you need to add it to the application startup class
@MapperScan("com.*.dao")//加上你项目的dao或service所在文件位置即可
Finally, the project started successfully.