Eclipse + Turn an Existing Project into a JPA Proj

2020-08-09 06:30发布

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?

5条回答
欢心
2楼-- · 2020-08-09 06:42

You could also Right Click the eclipse project and click on configure which allows you to convert to a JPA project.

alt text

查看更多
等我变得足够好
3楼-- · 2020-08-09 06:53

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.

查看更多
We Are One
4楼-- · 2020-08-09 07:00

project properties --> project facets. There you can click on the JPA check-box and you have an JPA project.

查看更多
对你真心纯属浪费
5楼-- · 2020-08-09 07:03

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.

查看更多
beautiful°
6楼-- · 2020-08-09 07:07

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.

查看更多
登录 后发表回答