views:

1258

answers:

6

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?

A: 

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.

Chris Nava
+2  A: 

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.

ptyx
A: 

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.

kosoant
Unless the plugins that define those natures have "add nature xxxx to project" type options on the project context menu. If such an option exists, use it, because it usually takes care of all the necessary changes (.project, .classpath, .settings/...)
Scott Stanchfield
A: 

Hello, I have a doubt, what's the difference between a JPA project and a not JPA project?

Turi
+1  A: 

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

Mark Baijens
A: 

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

alt text

Eric W