我有一个在 karaf(版本 3.0.3)中有多个模块的项目,我需要向 Xero API(发票网关)添加一个依赖项 - https://github.com/XeroAPI/Xero-Java
我通过felix apache使用OSGI实现。在模块中,我将所有依赖项添加到 Xero,这些依赖项都在 pom 波纹管中。
庞.xml
<dependency>
<groupId>com.github.xeroapi</groupId>
<artifactId>xero-java</artifactId>
<version>${xero-java.version}</version>
</dependency>
<dependency>
<groupId>com.github.xeroapi</groupId>
<artifactId>xeroapi-schemas</artifactId>
<version>${xero-schemas.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb-core.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb-impl.version}</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>${javax-activation.version}</version>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
<version>${threetenbp.version}</version>
</dependency>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>!com.google.api.client.http,*</Import-Package>
<Embed-Dependency>com.google.api.client.http</Embed-Dependency>
</instructions>
</configuration>
</plugin>
所有实现都已部署和编译,但在运行 karaf 时,我遇到了下一个错误。
原木卡拉夫
2019-07-19 15:44:19,812 |错误 | lix调度队列 |功能部署侦听器 |22 - org.apache.karaf.deployer.features - 3.0.3 |无法安装功能 java.lang.Exception: 无法启动捆绑包 mvn:com.xtpo.im/im-bll-impl/0.2-SNAPSHOT in feature(s) be-invoice-mgmt-0.2-SNAPSHOT: 捆绑包 com.xtpo.im.im-bll-impl [368] 中未解决的约束: 无法解析 368.0: 缺少要求 [368.0] osgi.wiring.package;(osgi.wiring.package=com.google.api.client.http) at org.apache.karaf.features.internal.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:504)[21:org.apache.karaf.features.core:3.0.3] at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeatures(FeaturesServiceImpl.java:459)[21:org.apache.karaf.features.core:3.0.3] at Proxya6f8789a_dbdc_4181_b0eb_837248e8cb78.installFeatures(未知来源)[:] at Proxycbafeabb_12c9_47e3_94d6_f999d20117fa.installFeatures(未知来源)[:] at org.apache.karaf.deployer.features.FeatureDeploymentListener.bundleChanged(FeatureDeploymentListener.java:213)[22:org.apache.karaf.deployer.features:3.0.3] at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:868)[org.apache.felix.framework-4.2.1.jar:] at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:789)[org.apache.felix.framework-4.2.1.jar:] at org.apache.felix.framework.util.EventDispatcher.run(EventDispatcher.java:1088)[org.apache.felix.framework-4.2.1.jar:] at org.apache.felix.framework.util.EventDispatcher.access$000(EventDispatcher.java:54)[org.apache.felix.framework-4.2.1.jar:] at org.apache.felix.framework.util.EventDispatcher$1.run(EventDispatcher.java:101)[org.apache.felix.framework-4.2.1.jar:] at java.lang.Thread.run(Thread.java:748)[:1.8.0_211] 原因:org.osgi.framework.BundleException:bundle com.xtpo.im.im-bll-impl [368]中未解析的约束:无法解析 368.0:缺少需求 [368.0] osgi.wiring.package;(osgi.wiring.package=com.google.api.client.http) at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)[org.apache.felix.framework-4.2.1.jar:] at org.apache.felix.framework.Felix.startBundle(Felix.java:2037)[org.apache.felix.framework-4.2.1.jar:] at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)[org.apache.felix.framework-4.2.1.jar:] at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)[org.apache.felix.framework-4.2.1.jar:] at org.apache.karaf.features.internal.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:501)[21:org.apache.karaf.features.core:3.0.3] ...10 更多
问题是com.google.api.client.http。有人可以帮我解决这个问题吗?
在文件功能中,我有下一个依赖项:
功能.xml
<!--Xero dependencies-->
<bundle>wrap:mvn:com.github.xeroapi/xero-java/${xero-java.version}</bundle>
<bundle>wrap:mvn:com.github.xeroapi/xeroapi-schemas/${xero-schemas.version}</bundle>
<bundle>wrap:mvn:javax.xml.bind/jaxb-api/${jaxb-api.version}</bundle>
<bundle>wrap:mvn:com.sun.xml.bind/jaxb-impl/${jaxb-impl.version}</bundle>
<bundle>wrap:mvn:javax.activation/activation/${javax-activation.version}</bundle>
<bundle>wrap:mvn:org.threeten/threetenbp/${threetenbp.version}</bundle>
谢谢大家
Felix 无法解析包com.google.api.client.http
。您必须部署包含该包的捆绑包,或将其嵌入到您自己的捆绑包中。该软件包可从maven artifact com.google.http-client:google-http-client获得。
您可以配置 maven-bundle-plugin 以嵌入编译范围的依赖项,并将依赖项添加到上面链接的 google http-client 工件中:
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.30.2</version>
</dependency>
可能需要对版本进行一些调整。请注意,该工件被打包为OSGi捆绑包,因此您也可以尝试下载它并将其与您自己的捆绑包一起部署到karaf(而不是嵌入它)。