[英]OSGi: Missing requirement osgi.wiring.package
我寫了一個包含5個模塊的項目。 我使用maven在intellij IDEA中創建它們,然后將“ OSGi”框架支持添加到所有模塊。 我使用maven-bundle-plugin配置導出程序包和導入程序包。 但是當我運行它時,總會出現錯誤:
org.osgi.framework.BundleException: Unable to resolve org.gxkl.launcher [12] (R 12.0): missing requirement [org.gxkl.launcher [12](R 12.0)] osgi.wiring.package; (osgi.wiring.package=org.gxkl.server).
啟動器模塊包含Bundle-Activator,並且org.gxkl.server軟件包位於服務模塊中。 我使用類似的pom來配置模塊,但是只有服務模塊出錯了。 啟動器中的pom文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>${parent.artifactId}</artifactId>
<groupId>${parent.groupId}</groupId>
<version>${parent.version}</version>
</parent>
<modelVersion>${model.version}</modelVersion>
<artifactId>launcher</artifactId>
<packaging>bundle</packaging>
<dependencies>
...
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>service</artifactId>
<version>${project.version}</version>
</dependency>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Activator>org.gxkl.Starter</Bundle-Activator>
<Export-Package>
org.gxkl
</Export-Package>
<Import-Package>
<!--some packages in other modules. They work fine-->
...
org.gxkl.server <!--packge in service modules. It doesn't work fine-->
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
服務中的pom文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>${parent.artifactId}</artifactId>
<groupId>${parent.groupId}</groupId>
<version>${parent.version}</version>
</parent>
<modelVersion>${model.version}</modelVersion>
<artifactId>service</artifactId>
<packaging>bundle</packaging>
<description>...</description>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>
org.gxkl.server,
...
</Export-Package>
<Import-Package>
...
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
該錯誤消息表示捆綁包launcher
程序org.gxkl.server
導入軟件包org.gxkl.server
但是在框架中沒有捆綁軟件會導出該軟件包。
順便說一句,您可以從POM中刪除<Import-Package>
部分。 不需要它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.