问题
Is there a way to turn a normal Eclipse Project into a JPA Project?
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?
回答1:
project properties --> project facets. There you can click on the JPA check-box and you have an JPA project.
回答2:
You could also Right Click the eclipse project and click on configure which allows you to convert to a JPA project.

回答3:
You'll want to modify:
- your .project
- your .classpath (eventually)
- your .settings if you're unlucky
As Chris Nava said, the best way to do that is to create an empty JPA project and compare it with yours.
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.
回答4:
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.
Edit: You may also need to compare the .classpath files.
回答5:
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.
来源:https://stackoverflow.com/questions/703043/eclipse-turn-an-existing-project-into-a-jpa-project