我正在使用maven-bundle-plugin
并尝试捆绑Google地图依赖项。
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-ClassPath>*;scope=compile|runtime</Bundle-ClassPath>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Directory>OSGI-INF/lib</Embed-Directory>
<Import-Package>
*
</Import-Package>
<_exportcontents>
*
</_exportcontents>
</instructions>
</configuration>
</plugin>
当我检查JAR(Manifest.MF)时,我可以在com.google.maps.model
中看到Export-Package
但在Import-Package
中看不到。我怎样才能在Import-Package
中获得它?
此问题与之前未解决的问题How to import a class from third party jar file in an OSGi component
相关联答案 0 :(得分:0)
嗯,导入包中不应该有任何内容,因为你没有导入谷歌地图类,你正在嵌入它们。您将google jar打包在自己的包中,只有当您想要使用从另一个包中导出的类时,Import-Package才适用。
从另一个问题来看,我并不完全确定(我根本不使用maven bundle插件)但是'exportcontents *'似乎很可疑,导出太多会导致细微的问题。
我会先说不出口,然后根据需要添加包。
答案 1 :(得分:0)
如果要在jar中嵌入jar并想要访问其类,请使用Include-Resource指令,它可以选择展开JAR资源(请参阅@选项)