【发布时间】:2013-05-13 15:17:38
【问题描述】:
我使用 Eclipse 和 Maven(m2eclipse 插件)和 JIBX 来(un)编组 XML。
如果我像这样使用工厂,它会起作用:
IBindingFactory bindingFactory = BindingDirectory.getFactory(mappedClass);
但是我想根据绑定文件创建一个工厂,因为这是由自动生成的服务存根完成的。所以我在 TestNG 中运行了以下测试:
@Test
public void testBindingFactory() {
try
{
IBindingFactory factory = BindingDirectory.getFactory("binding", "");
} catch (JiBXException e)
{
e.printStackTrace();
fail(e.getMessage());
}
}
它失败并显示以下错误消息:
Unable to access binding 'binding'
Make sure classes generated by the binding compiler are available at runtime
java.lang.ClassNotFoundException: .JiBX_bindingFactory
名称(文件名是binding.xml)是正确的,空的“”表示没有包,这也是正确的,但我猜可能是个问题?
工厂是在我的项目文件夹target/classes/JiBX_bindingFactory.class下生成的,所以应该可以找到! (请记住,如果我指定一个具体的顶级绑定类,一切正常)
任何帮助将不胜感激!
我的 pom.xml 文件中的构建部分:
<build>
<plugins>
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.5</version>
<configuration>
<schemaBindingDirectory>src/main/config</schemaBindingDirectory>
<includeSchemaBindings>
<includeSchemaBinding>binding.xml</includeSchemaBinding>
</includeSchemaBindings>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<goals>
<!-- Do we require other goals? http://jibx.sourceforge.net/maven-jibx-plugin/ -->
<goal>bind</goal>
<!-- goal>test-bind</goal-->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
【问题讨论】:
标签: binding classnotfoundexception jibx