如何在Netbeans中使用Eclipse-Link JPA应用静态编织Ant任务? [英] How to apply Static Weaving Ant Task with Eclipse-Link JPA in Netbeans?

查看:160
本文介绍了如何在Netbeans中使用Eclipse-Link JPA应用静态编织Ant任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Netbeans 7.1.1和Glassfish 3.1.2服务器。作为JPA提供商,我决定使用随Netbeans一起提供的eclipse-link 2.3.0。由于我想使用延迟抓取,我的项目由大约45个JPA实体类组成,它们之间有很多关系,我决定使用静态编织。此外,@ Entity类位于单独的类Lib项目中,而persistence.xml驻留在EJB项目中。

I am using Netbeans 7.1.1 and a Glassfish 3.1.2 server. As JPA provider I decided to use eclipse-link 2.3.0 which is shipped with Netbeans. Since I want to use lazy fetching and my project consists of roughly 45 JPA Entity classes which do have lots of relations among them, I decided to use static weaving. Moreover, the @Entity classes are in a separate Class Lib Project, whereas the persistence.xml resides in the EJB project.

我已按照此处的说明操作: http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving

I already followed the instructions here: http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving

我将ant-task放入build-impl.xml文件(如下)。使用Netbeans时这是正确的吗?这是build-impl.xml的片段:

I put the ant-task into the build-impl.xml file (below ). Is that correct when using Netbeans ? Here's the snippet from build-impl.xml:

<target name="-post-jar" description="New task definition for EclipseLink static weaving">
    <taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask"/>
</target>
<target name="weaving" description="perform weaving" depends="-post-jar">
    <weave  source="${dist.jar}\MyProject.jar"
            target="${dist.jar}\MyProject_Weaved.jar"
            persistenceinfo="${dist.jar}..\..\MyProjectEE\MyProject-ejb\build\classes\META-INF\persistence.xml"
            loglevel="FINER">
        <classpath>
            <pathelement path="${dist.jar}\lib\eclipselink-2.3.0.jar"/>
            <pathelement path="${dist.jar}\lib\javaee-api-6.0.jar"/>
            <pathelement path="${dist.jar}\lib\jasypt-1.9.0.jar"/>
            <pathelement path="${dist.jar}\lib\javax.persistence-2.0.jar"/>
            <pathelement path="${dist.jar}\lib\org.eclipse.persistence.jpa.jpql_1.0.0.jar"/>
            <pathelement path="${dist.jar}\lib\joda-time-2.1.jar"/>
            <pathelement path="${dist.jar}\lib\jms.jar"/>
        </classpath>
    </weave>
</target>

pathelement路径中的所有jar文件也作为库包含在Netbeans IDE中。当点击Clean& Build时,我现在收到以下错误:

All jar-files in the pathelement paths are also included as libraries in the Netbeans IDE. When hitting "Clean & Build", I now get the following error:

D:\workspace\MyProject\nbproject\build-impl.xml:703: taskdef class org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask cannot be found
using the classloader AntClassLoader[]

我在这里犯了什么错误?

What do I make wrong here ?

推荐答案

您需要将eclipselink.jar和javax.persistence.jar添加到Ant类路径。

You need to add the eclipselink.jar and javax.persistence.jar to the Ant classpath.

在Netbeans中,转到Tools / Options / Miscellaneous / Ant,然后编辑类路径那里。

In Netbeans go to Tools / Options / Miscellaneous / Ant, and edit the classpath there.

这篇关于如何在Netbeans中使用Eclipse-Link JPA应用静态编织Ant任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆