简体   繁体   English

如何使用Spring Boot和IntelliJ Idea从数据库生成实体类?

[英]How can I generate entities classes from database using Spring Boot and IntelliJ Idea?

我尝试使用Spring Initializr向导创建一个项目,我已经有了一个数据库,所以我想使用Spring Boot和IntelliJ Idea生成实体类。

Prerequisites are: 先决条件是:

  1. You have your Spring Boot project initialized correctly in IDEA 您在IDEA中正确初始化了Spring Boot项目
  2. JPA persistence.xml file or similar has been generated correctly 已正确生成JPA persistence.xml文件或类似文件

Then you have to do these things: 然后你必须做这些事情:

  1. Create a DataSource - here you will add a simple DataSource that will connect to your database. 创建一个DataSource - 在这里,您将添加一个将连接到您的数据库的简单DataSource。 The setup should be intuitive - you only provide connection details and add DB drivers (IDEA can download them for you) 设置应该是直观的 - 您只提供连接详细信息并添加数据库驱动程序(IDEA可以为您下载)
  2. Add JPA/Hibernate facet. 添加JPA / Hibernate方面。 You can do it like this or this . 你可以像这样这样
  3. Now you should be able to generate entities using IDEA . 现在,您应该能够使用IDEA生成实体 What you want to do here is choose Generate by Database Schema . 您要在此处执行的操作是选择“ Generate by Database Schema The dialog will let you select the tables you want to use, the rest should be up to you. 该对话框将允许您选择要使用的表,其余的应由您决定。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在IntelliJ IDEA中从Oracle数据库生成实体? - How can I generate entities from oracle database in intellij idea? 在 Intellij Idea 中使用 hibernate 从实体类生成数据库表(不使用 Spring) - Generate Database Tables From Entity Classes using hibernate in Intellij Idea (Not using Spring) 从 IntelliJ 11 IDEA 中的实体生成表 - Generate tables from entities in IntelliJ 11 IDEA 如何使用Spring Boot JPA在这两个类之间建立一对一的关系?另外,如何保存实体? - How can i establish a one to one relationship between this two classes using spring boot jpa?, also, how do i save the entities? 在intellij idea中找不到spring启动插件 - can not find the spring boot plugin in intellij idea 如何使用 spring 引导从数据库创建实体类? - How to create entity classes from database using spring boot? 当我在 IntelliJ IDEA 中导入 Spring 引导项目时,Java 类看起来不同(.java) - Java classes looks different (.java) when I imported a Spring Boot project in IntelliJ IDEA 如何在Intellij Idea中以不同方式突出显示库类? - How can I highlight library classes differently in Intellij Idea? 我如何在 IntelliJ IDEA 中使用来自另一个项目的类? - How do I use classes from another project in IntelliJ IDEA? 如何在Gradle项目中使用IntelliJ IDEA生成包含javadoc的.jar? - How can I generate a .jar that also includes javadoc in it using IntelliJ IDEA in a Gradle project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM