简体   繁体   English

NetBeans中的Scala JPA

[英]Scala JPA in netbeans

I am learning Java EE 6 but wants my Entities in scala and am also using netbeans. 我正在学习Java EE 6,但希望在scala中使用我的实体,并且还在使用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. 我创建了一个scala类库,但是即使添加了eclipselink库,我也无法导入javax.persistence._。 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. 注意:我尝试过eclipse,但是总是遇到问题,尤其是关于glassfish,因此我想使用netbeans,并且让Java Web项目依赖于scala类库。 I also like vim and netbeans have a perfect plugin for that. 我也喜欢vim,而netbeans为此提供了一个完美的插件。 Not dishing eclipse but I am always suffering when I tried to use eclipse with Java EE 6 compared to netbeans. 与netbeans相比,当我尝试在Java EE 6上使用eclipse时,我不会一直遭受日食的困扰。

You can use Maven to configure your dependencies for JavaEE and your specific JPA provider, for example: 您可以使用Maven为JavaEE和特定的JPA提供程序配置依赖项,例如:

<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. 要使用javax.persistence类,您需要javax.persistence依赖项。
  • Im using Java EE 7 but in your case, change "7.0" to "6.0" 我正在使用Java EE 7,但在您的情况下,请将“ 7.0”更改为“ 6.0”
  • Toplink is my JPA provider (you can use EclipseLink, Hibernate, ...), for example: Toplink是我的JPA提供程序(您可以使用EclipseLink,Hibernate等),例如:
  <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 或通过此链接的其他提供商: JPA提供商

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM