I am learning Java EE 6 but wants my Entities in scala and am also using netbeans. I created a scala class library but I cannot use javax.persistence._ even if I add the eclipselink library I can't import it. NB: I've tried eclipse but always having problems especially with glassfish thus I want to use netbeans and have java web project depend on the scala class library. I also like vim and开发者_开发问答 netbeans have a perfect plugin for that. Not dishing eclipse but I am always suffering when I tried to use eclipse with Java EE 6 compared to netbeans.
You can use Maven to configure your dependencies for JavaEE and your specific JPA provider, for example:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>toplink.essentials</groupId>
<artifactId>toplink-essentials</artifactId>
<version>2.1-60f</version>
</dependency>
Notes:
- To use javax.persistence classes, you need javax.persistence dependency.
- Im using Java EE 7 but in your case, change "7.0" to "6.0"
- Toplink is my JPA provider (you can use EclipseLink, Hibernate, ...), for example:
<dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.jpa</artifactId> <version>2.6.0</version> </dependency>
Or another provider at this link: JPA provider
精彩评论