5

我有一个使用 Eclipselink 2.5 的应用程序,在运行 Junit 测试用例时,我总是收到以下警告:

[EL Warning]: metadata: 2013-08-19 01:14:05.142--ServerSession(14351551)--
Reverting the lazy setting on the OneToOne or ManyToOne attribute [currentTransit]
for the entity class [class ......persistent.entity.BPExecutionEntity] since
weaving was not enabled or did not occur.

所以,我在我的 Ant 构建文件上写了一个“编织”任务,如下所示:

<target name="define.task" 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="define.task">
    <weave  source="D:\...\dist\${ant.project.name}.jar"
            target="D:\...\dist\woven-${ant.project.name}.jar"
            persistenceinfo="D:\...\lib\persistence.jar">
        <classpath>
        </classpath>
    </weave>
</target>

好的,一切正常,当我编译代码时,它会生成一个已编译 jar 一半大小的编织文件。但是,当我运行项目的测试时,我仍然收到相同的警告blah blah blah... since weaving was not enabled or did not occur.

有人知道如何从我的测试中删除此警告吗?

4

2 回答 2

4

我终于使用动态编织解决了这种情况。当我使用 Netbeans 7.3.1 时,我去了Project Options | Run | VM options并添加了以下文本:-javaagent:C:\eclipselink\jlib\eclipselink.jar,您可以将地址更改为您在 eclipselink.jar 中找到的任何地址。

然后我将此行添加到persistence.xml

<property name="eclipselink.weaving" value="true"/>

就这样。此配置使动态编织能够执行测试用例并删除[EL Warning] Reverting the lazy setting on the OneToOne or ManyToOne attribute...etc.

于 2013-08-21T14:27:26.807 回答
3

您需要指定在您的 persistence.xml 属性中使用静态编织。请参阅 http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving

“第 2 步:配置 persitence.xml”了解详细信息

于 2013-08-19T13:10:51.207 回答