Eclipse + 将现有项目转换为 JPA 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/703043/
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
Eclipse + Turn an Existing Project into a JPA Project
提问by mainstringargs
Is there a way to turn a normal Eclipse Project into a JPA Project?
有没有办法将普通的 Eclipse 项目变成 JPA 项目?
I have a normal project with Entities in it and a Persistence.xml file, but it is not an eclipse recognized JPA project. What can I do?
我有一个包含实体的普通项目和一个 Persistence.xml 文件,但它不是 Eclipse 认可的 JPA 项目。我能做什么?
回答by Mark Baijens
project properties --> project facets. There you can click on the JPA check-box and you have an JPA project.
项目属性 --> 项目方面。在那里您可以单击 JPA 复选框,您就有了一个 JPA 项目。
回答by Eric Warriner
You could also Right Click the eclipse project and click on configure which allows you to convert to a JPA project.
您也可以右键单击 eclipse 项目并单击配置,这允许您转换为 JPA 项目。
回答by ptyx
You'll want to modify:
你会想要修改:
- your .project
- your .classpath (eventually)
- your .settings if you're unlucky
- 你的 .project
- 你的 .classpath (最终)
- 如果你不走运,你的 .settings
As Chris Nava said, the best way to do that is to create an empty JPA project and compare it with yours.
正如 Chris Nava 所说,最好的方法是创建一个空的 JPA 项目并将其与您的项目进行比较。
I found it is sometimes necessary to delete your original project (do not "delete project content on disk" !) and reimport it to make Eclipse happy.
我发现有时需要删除您的原始项目(不要“删除磁盘上的项目内容”!)并重新导入它以使 Eclipse 满意。
回答by kosoant
Modifying the .project file by hand is the best way to add different "natures" to an Eclipse project. Like ptyx said: compare your current .project file to that of a project where the nature is what you want and merge the differences.
手动修改 .project 文件是向 Eclipse 项目添加不同“性质”的最佳方式。就像 ptyx 说的:将您当前的 .project 文件与您想要的性质的项目文件进行比较并合并差异。
回答by Chris Nava
Eclipse knows the project type via the .project file in the root of the project. Try creating a new JPA project and compare the .project files.
Eclipse 通过项目根目录中的 .project 文件知道项目类型。尝试创建一个新的 JPA 项目并比较 .project 文件。
Edit: You may also need to compare the .classpath files.
编辑:您可能还需要比较 .classpath 文件。