栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Apache Maven Assembly Plugin无法与OSGi捆绑包一起使用

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Apache Maven Assembly Plugin无法与OSGi捆绑包一起使用

我不得不做很多事情来使您的样本重复这个问题。

首先,您的反应堆订单在父母中是错误的。这就是为什么您必须一直进行mvn安装的原因。

<modules>    <module>OSGiDmHelloWorldProvider</module>    <module>OSGiDmHelloWorldConsumer</module>    <module>main</module>    <module>dist</module></modules>

接下来,如果您在父级中定义依赖项(例如JUnit),则无需在子级中重新定义它。

接下来,通常将父标签放在pom的顶部。

我看不出有一个让您的子模块与父模块版本不同的原因,因此我删除了标签,因此它们都

1.0-SNAPSHOT
来自父模块。

接下来,您在OSGiDmHelloWorldProvider依赖项中具有错误的组ID(应为rev)。

    <dependency>        <groupId>rev</groupId>        <artifactId>OSGiDmHelloWorldProvider</artifactId>        <version>1.0-SNAPSHOT</version>    </dependency>

在主模块中,您有一个不在反应堆中的依赖项。我猜这只是对样本的疏忽。

    <dependency>        <groupId>rev</groupId>        <artifactId>core</artifactId>        <version>1.0-SNAPSHOT</version>    </dependency>

毕竟,一切

mvn clean package -DskipTests=true
正常。

您的Main类中有一个硬编码的字符串,显然对我不起作用。(您可能还想看看免费的IDEA社区,而不是Eclipse!)

String baseDir = "D:/standAloneDev/java/workingDir/Sample Projects/Eclipse/Gen/OSGiDmHelloWorld/dist/target/dist-1.0-SNAPSHOT-bin/plugins/";

您应该将此相对。例如

File baseDir = new File("dist/target/dist-1.0-SNAPSHOT-bin/plugins/");String baseDirPath = baseDir.getAbsolutePath();loadScrBundle(framework);File provider = new File(baseDirPath, "OSGiDmHelloWorldProvider-1.0-SNAPSHOT.jar");File consumer = new File(baseDirPath, "OSGiDmHelloWorldConsumer-1.0-SNAPSHOT.jar");framework.getBundleContext().installBundle(provider.toURI().toString());framework.getBundleContext().installBundle(consumer.toURI().toString());

无论如何,得到它后,我在上注意到了以下javadoc

bundle.getSymbolicName()

Returns the symbolic name of this bundle as specified by its Bundle-SymbolicName manifest header. The bundle symbolic name should be based on the reverse domain name naming convention like that used for java packages.

因此,在org.apache.felix.scr-1.6.2.jar的MANIFEST.MF中

Bundle-Name: Apache Felix Declarative ServicesBundle-SymbolicName: org.apache.felix.scr

您没有这个,因为您没有创建清单并将其添加到jar中。

您需要添加一个执行阶段,并告诉jar插件使用清单:

        <plugin> <artifactId>maven-jar-plugin</artifactId> <configuration>     <archive>         <manifestFile>${project.build.outputDirectory}/meta-INF/MANIFEST.MF</manifestFile>     </archive> </configuration>        </plugin>        <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <executions>     <execution>         <id>bundle-manifest</id>         <phase>process-classes</phase>         <goals>  <goal>manifest</goal>         </goals>     </execution> </executions> <extensions>true</extensions> <configuration>     <instructions>         <Bundle-SymbolicName>OSGiDmHelloWorldProvider</Bundle-SymbolicName>         <Export-Package>com.bw.osgi.provider.able</Export-Package>         <Bundle-Activator>com.bw.osgi.provider.ProviderActivator</Bundle-Activator>         <Bundle-Vendor>Baptiste Wicht</Bundle-Vendor>     </instructions> </configuration>        </plugin>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/398247.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号