[英]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:从数据库表映射 -> 实体:
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 个类复制粘贴到您的项目中。
IntelliJ: Install plugin JPA Buddy and make a reverse engineering: Reverse engineering video IntelliJ:安装插件JPA Buddy并进行逆向工程: 逆向工程视频
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. 您可以创建模型来映射表及其与其他表的关系。
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
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.