[英]Apache Felix OSGI installing dependencies
我已經將maven-bundle-plugin
恢復為使用默認值。 這是我當前的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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.felix.test</groupId>
<artifactId>com.felix.test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.9.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-osgi</artifactId>
<version>4.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.4</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.4</version>
<extensions>true</extensions>
<configuration>
<instructions>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
一切都捆綁並安裝確定。 當我嘗試啟動捆綁軟件時,被告知我缺少安裝的net.sf.ehcache
。 然后我丟失了我安裝的slf4j.api
。 然后我想念slf4j.impl
,我嘗試從https://jpm4j.org/#!/安裝幾乎所有slf4j.impl
可能性,但大多數( slf4j-simple-1.7.12.jar
, slf4j-log4j12-1.7.12.jar
)報告:
org.osgi.framework.BundleException:片段捆綁包無法啟動。
這是我目前來自GoGo的錯誤:
org.osgi.framework.BundleException:無法解析com.felix.test [16](R 16.0):缺少要求[com.felix.test [16](R 16.0)] osgi.wiring.package; (&(osgi.wiring.package = net.sf.ehcache)(version> = 2.10.0)(!(version> = 3.0.0)))[原因:無法解析net.sf.ehcache [17] (R 17.0):缺少要求[net.sf.ehcache [17](R 17.0)] osgi.wiring.package; (&(osgi.wiring.package = org.slf4j)(version> = 1.7.0)(!(version> = 2.0.0)))[原因:無法解析slf4j.api [23](R 23.0) :缺少要求[slf4j.api [23](R 23.0)] osgi.wiring.package; (&(osgi.wiring.package = org.slf4j.impl)(版本> = 1.6.0))]]未解決的要求:[[com.felix.test [16](R 16.0)] osgi.wiring.package; (&(osgi.wiring.package = net.sf.ehcache)(版本> = 2.10.0)(!(版本> = 3.0.0))))]
希望我越來越近...
謝謝!
您有兩個錯誤要解決。 第一個是“片段束無法啟動”。 錯誤消息會告訴您所有您需要了解的內容。 slf4j實現捆綁包是片段,您無法啟動片段。 所以就不要啟動它們!
您尚未指定如何運行OSGi框架,但必須在某處必須有一些代碼可以迭代所有已安裝的包並在每個包上調用start()
方法。 您需要修改代碼以不對作為片段的捆綁軟件調用start()
。 您可以按以下步驟判斷是否捆綁包是片段:
(bundle.adapt(BundleRevision.class).getTypes() | BundleRevision.TYPE_FRAGMENT) > 0;
要么:
bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null;
第二個錯誤說名為com.felix.test
的捆綁com.felix.test
對包net.sf.ehcache
有依賴性。 我從未聽說過com.felix.test
...這是您正在構建的捆綁軟件嗎? 您實際上在代碼中使用了Ehcache嗎? 如果是這樣,顯然您需要安裝Ehcache捆綁包。 如果您確實安裝了Ehcache,則它可能是錯誤的版本。 您的捆綁軟件要求的版本為2.10.0,但不包括3.0.0。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.