我有一个使用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>
好的,一切正常,当我编译代码时,它会生成一个编织文件大小一半的编织文件。但是,当我运行项目的测试时,我仍然收到相同的警告blah blah blah... since weaving was not enabled or did not occur.
有人知道如何从我的测试中删除此警告吗?
答案 0 :(得分:2)
您需要指定在persistence.xml属性中使用静态编织。看到 http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving
“步骤2:配置persitence.xml”了解详细信息
答案 1 :(得分:2)
我终于用动态编织解决了这个问题。当我使用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.