简体   繁体   English

如何使用 spring 引导从数据库创建实体类?

[英]How to create entity classes from database using spring boot?

I'm working on a spring boot application using spring data jpa at Spring Tool Suite IDE. I need to create entity classes from database but I couldn't find any answer to how to do it.我正在使用 spring 数据 jpa Spring 工具套件 IDE 中的 spring 启动应用程序。我需要从数据库创建实体类,但我找不到如何做的答案。

I saw an answer about adding JPA Facet adding and using it.我看到了关于添加 JPA Facet 添加和使用它的答案。 But I couldn't add JPA Facet because my application is maven web, not jee application.但是我无法添加 JPA Facet,因为我的应用程序是 maven web,而不是 jee 应用程序。

Mapping from db table -> entity:从数据库表映射 -> 实体:

  1. Eclipse: Make an empty JPA Project, set data sources and use JPA Tools > Generate entities from Tables. Eclipse:创建一个空的 JPA Project,设置数据源并使用 JPA Tools > Generate entities from Tables。 Then copy-paste model classes to your project.然后将 model 个类复制粘贴到您的项目中。 JPA 工具

  2. IntelliJ: Install plugin JPA Buddy and make a reverse engineering: Reverse engineering video IntelliJ:安装插件JPA Buddy并进行逆向工程: 逆向工程视频

  3. Netbeans: How to Netbeans: 如何


If you know other ways to generate entities, please tell us.如果您知道其他生成实体的方法,请告诉我们。

You don't create entity classes from database. 您不从数据库创建实体类。 You create models to map your table and its relationships with other tables. 您可以创建模型来映射表及其与其他表的关系。

  1. Application Properties to configure JPA mapping. 应用程序属性以配置JPA映射。

https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

  1. Map your classes to a table. 将您的类映射到表。

https://www.vogella.com/tutorials/JavaPersistenceAPI/article.html#simple https://www.vogella.com/tutorials/JavaPersistenceAPI/article.html#simple

暂无
暂无

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

相关问题 有没有一种简单的方法可以使用没有实体/ pojo类的spring boot从mongodb数据库的集合中查询特定文档? - Is there a simple way for querying a specific document from a collection of a mongodb database using spring boot without entity/pojo classes? 春天的靴子。从MySql架构自动创建实体类 - Spring boot. Automatically create Entity classes from MySql schema 在Spring Boot中如何从实体类中调用基于服务的类 - How to call service based classes from entity class in spring boot 如何跳过某些 @Entity 类在 Spring Boot 的 h2(内存中)数据库中创建为表? - How do I skip certain @Entity classes from being created as a table in h2 (in memory) database in Spring Boot? 如何使用Spring Boot和IntelliJ Idea从数据库生成实体类? - How can I generate entities classes from database using Spring Boot and IntelliJ Idea? 如何使用 JDBC 在 spring 引导测试类上创建事务上下文? - How to create a transactional context on spring boot test classes using JDBC? 如何使用非实体表在 Spring Boot 上创建自定义 @Query? - How to create a custom @Query on Spring Boot using a non Entity table? 如何使用 spring 引导从数据库 MYSQL 数据库创建动态菜单 - How to create Dynamic Menu from Database MYSQL database with spring boot Spring 引导:如何使用复合键创建实体 - Spring Boot: How to create an Entity with a composite key 如何从 Spring Boot 以编程方式创建数据库模式 - How to create database schema programatically from Spring boot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM