2

所以我的POM中有这样的东西:

<dependency>
  <!-- jsoup HTML parser library @ http://jsoup.org/ -->
  <groupId>org.jsoup</groupId>
  <artifactId>jsoup</artifactId>
  <version>1.7.1</version>
</dependency>   

jsoup-1.7.1.jar从某个地方的 maven repo 获取并将其放在我的Maven Dependencies文件夹中。

现在我可以在我的代码中使用它(Eclipse 不会抱怨),但是当我尝试在我的MANIFEST.MF文件中添加对它的依赖时:

Import-Package: org.osgi.framework, org.jsoup, org.jsoup.nodes

Eclipse 一直在抱怨:

No available bundle exports package 'org.jsoup.nodes'
No available bundle exports package 'org.jsoup'

有人可以向我解释为什么会这样吗?(我很好奇确定MANIFEST.MF看到什么的过程)

4

2 回答 2

2

When you work with the eclipse PDE you have to create a target platform that contains all necessary bundles. The normal dependency resolution is not coupled with the target platform. So you have to add each dependency to the to the maven pom and to the target platform.

Btw. if you are working on a server based OSGi project it may be better to not use the PDE. You can also create bundles using the maven bundle plugin. It analyzes the imports you do and creates the manifest automatically. In most cases this is much better than the PDE manifest first way and it works better with maven.

See: http://www.liquid-reality.de/display/liquid/2011/02/15/Karaf+Tutorial+Part+1+-+Installation+and+First+application

于 2012-12-06T08:54:32.167 回答
0

只需在该包清单文件中添加一个导出语句,记住每次导入都应该有导出在此处输入链接描述

于 2016-05-02T09:39:31.890 回答