gpt4 book ai didi

java - 使用 Maven 构建 OSGI 声明式服务

转载 作者:行者123 更新时间:2023-11-30 09:35:56 27 4
gpt4 key购买 nike

我在使用 Maven 构建 OSGI 服务时遇到问题。我的 pom.xml :

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.0.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Service-Component>OSGI-INF/activator.xml</Service-Component>
<Import-Package>org.osgi.framework</Import-Package>
</instructions>
</configuration>
</plugin>

当我使用 Maven 安装 构建时,生成了 .jar 文件,但 OSGI-INF 文件夹不存在。我使用 Eclipse 和 m2e 插件。为什么 .jar 文件中没有 OSGI-INF 文件夹?

最佳答案

所以如果你想使用 bnd 的内部注释框架,你不需要依赖 felix scr 插件。

    <dependency>
<groupId>biz.aQute</groupId>
<artifactId>bndlib</artifactId>
<version>1.50.0</version>
</dependency>

完成后,您可以告诉 bnd 使用此配置选项生成声明式服务 xml 到 maven-bundle-plugin:

    <Service-Component>*</Service-Component>

这将为您生成 OSG-INF 内容。注释略有不同,它们记录在此处:http://www.aqute.biz/Bnd/Components

此外,您的导入看起来真的很时髦,我会推荐这个:

    <instructions>
<Export-Package>{local-packages};version="${project.version}"</Export-Package>
<Import-Package>*</Import-Package>
<Private-Package>{local-packages}</Private-Package>
<Service-Component>*</Service-Component>
</instructions>

关于java - 使用 Maven 构建 OSGI 声明式服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11038487/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com