前言

这里介绍IDEA根据数据库逆向生成Entity,数据库为Mysql。


具体实现

IDEA连接Mysql

  • View -》Tool Windows -》Database 调出Database面板

SpringBoot - IDEA逆向生成Entity_ide

  • "✚" -》Data Source -》数据库类型

SpringBoot - IDEA逆向生成Entity_ide_02

  • 新建数据源

SpringBoot - IDEA逆向生成Entity_数据源_03

  • 连接建立如下:

SpringBoot - IDEA逆向生成Entity_右键_04


逆向生成Entity

  • View -》Tool Windows -》Persistence调出Persistence面板
  • 注:Persistence面板找不到看文章最后一节

SpringBoot - IDEA逆向生成Entity_SpringBoot_05

  • 项目右键 -》Generate Persistence Mapping -》By Database Schema

SpringBoot - IDEA逆向生成Entity_SpringBoot_06

  • 选择数据源、生成包目录、勾选需要生成的数据表,点击OK

SpringBoot - IDEA逆向生成Entity_mysql_07

  • 生成结果如下

SpringBoot - IDEA逆向生成Entity_ide_08


Persistence面板调出

注: 在View -》Tool Windows -》中找不到Persistence面板时可根据如下步骤调出:

  • 点击View -》Project Structure,调出Project Structure面板。
  • 在调出Project Structure面板的项目名上右键 -》Add -》JPA ,给项目添加JPA模块。
  • 在JPA面板中下方的Default JPA Provider选项选择JPA的提供者Hibernate,点击OK。
 
以上为本篇文章的主要内容,希望大家多提意见,如果喜欢记得点个推荐哦
作者:Maggieq8324
本文版权归作者,欢迎转载,转载时保留原作者和文章地址即可。