java IntelliJ IDEA 2016:请选择持久化单元

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38100509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 03:06:52  来源:igfitidea点击:

IntelliJ IDEA 2016: Please choose persistence unit

javahibernatejpaintellij-idea

提问by Do Nhu Vy

I try to atomatic generate entities by IntelliJ IDEA but not success.

我尝试通过 IntelliJ IDEA 自动生成实体,但没有成功。

error: Please choose presistence unit.

错误:请选择存在单位。

enter image description here

enter image description here

Help me generate entity and mapping files.

帮我生成实体和映射文件。

回答by Robyn Liu

I've got the similar problem.Here is my solution.

我有类似的问题。这是我的解决方案。

  1. add "JPA" facet.
    open the "Project Structure" window -> click the "Facets" -> click the "add" button -> select "JPA"

  2. add JPA persistence.xml.
    add persistenceclick "persistence" -> right click your root item in the "persistence" toolbar -> "Generate Persistence Mapping" -> "By Database Schema".

  3. generate entities.
    Step 3
  1. 添加“JPA”方面。
    打开“项目结构”窗口 -> 点击“Facets” -> 点击“添加”按钮 -> 选择“JPA”

  2. 添加 JPA 持久性.xml。
    add persistence单击“持久性”-> 在“持久性”工具栏中右键单击您的根项目->“生成持久性映射”->“按数据库架构”。

  3. 生成实体。
    Step 3

回答by Yuechuan Xiao

you need add "hibernate.cfg.xml" first

您需要先添加“hibernate.cfg.xml”

Project Structure -> Modules -> Hibernate add hibernate.cfg.xml

项目结构 -> 模块 -> Hibernate添加 hibernate.cfg.xml