繁体   English   中英

jar包及其ServiceMix-karaf中的类路径

[英]jar bundle and its classpath in ServiceMix-karaf

我正在开发2个jar文件(jar1和jar2-2个jar的pom.xml中的包装类型为jar),并将它们安装到serviceMix中。 Jar1将使用jar2中的一些packake。

在manifest.mf文件中,我使用jar1和jar2的导入和导出。 安装到serviceMix 4.3.0之后。 一切都很好。 从jar 1,我可以使用jar2中的包(我知道通过调试代码)。 但是问题在这里:

The structure of Jar2: 
  jar2:/ 
        . 
        com 
               abc 
                   .......(classes) 
        META-INF 
               MANIFEST.MF 
        FactoryContext.xml 

The short version of jar2's MANIFEST.MF is 
   Bundle-ClassPath: . 
   Bundle-Name: jar2 
   Bundle-SymbolicName: jar2 
   Bundle-Version: 1.0.0 
   Export-Package: com.abc 
   Import-Package: xyz 
   Tool: Bnd-1.50.0 

Jar1调用Jar2的方法,该方法使用波纹管语句

context = new ClassPathXmlApplicationContext(“ FactoryContext.xml”);

每当涉及到该语句时,它总是会抛出异常,表明FactoryContext.xml不存在。 (我邀请这个文件不在类路径中)

你知道如何使它工作吗?

我也在ServiceMix论坛上发布了我的问题,我从Freeman-2得到了答案。 这是答案

You can try to put  FactoryContext.xml in a unique folder like META- 
INF/MyFactoryContext/FactoryContext.xml, then jar2 also export package   
META-INF.MyFactoryContext, and jar1 import package META- 
INF.MyFactoryContext, and  then should be able to use code like 
context = new ClassPathXmlApplicationContext("META-INF/ 
MyFactoryContext/FactoryContext.xml"); 
in jar1.

这是链接http://servicemix.396122.n5.nabble.com/question-about-jar-bundle-and-classpath-td5602052.html

暂无
暂无

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

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