我刚接触过OSGI,并试图部署我的第一个应用程序。我的pom中有一个春天的依赖。在部署过程中,我意识到Felix运行时需要所有传递依赖项才能正确安装包。从那以后,我一直在努力解决这个问题。我尝试过嵌入式依赖和嵌入式传递选项,但没有运气。这是我的酒。
<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.test</groupId>
<artifactId>taxonomydaobundle</artifactId>
<version>1.0.0</version>
<packaging>bundle</packaging>
<name>Taxonomy Dao Bundle</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>fusesource</id>
<url>http://repo.fusesource.com/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>apache-public</id>
<url>https://repository.apache.org/content/groups/public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>taxonomymodelbundle</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.0.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>com.test.taxonomy.api.*;version=1.0.0
</Export-Package>
<Import-Package>com.test.taxonomy.message.*;version=1.0.0,
*
</Import-Package>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>最初,我尝试使用mvn安装,但它只包含直接依赖项,而不是传递依赖项。在阅读了felix插件文档之后,我使用了org.apache.felix:maven-bundle-plugin:bundleall. mvn。但是,执行失败了,因为它无法从其使用的存储库中获取所需的jar文件。查看日志,我可以看到它指的是http://repo1.maven.org/maven2存储库,它没有所需的版本。例如,这个是来自于他的3.1.3,以及其他的。
[INFO] Unable to find resource 'hessian:hessian:pom:3.1.3' in repository central
(http://repo1.maven.org/maven2)如果有人能分享他们在这方面的经验,我将不胜感激。
-Thanks
发布于 2011-06-10 07:39:54
在OSGi环境中,部署所需库的常见方法是将它们作为自己的包部署。如果库没有启用OSGi,并且对于OSGi容器中的其他包来说,嵌入库是一个最常用的选项(如我所知)。
因此,如果您的包依赖于其他库,那么首先应该查看一下,如果这些库是OSGi包,并将它们作为自己的包安装在OSGi容器中。
如果您使用一个未启用OSGi的库,您可以查看一些提供这些库的OSGi启用的“包装”包的地方。
Spring是启用OSGi的--您应该可以单独部署这些包。我还建议您看看弹簧动模 (文档)。如果您构建了支持Spring的捆绑包,您还可以从已经准备好这些包的OSGi容器开始。我对熔断器ESB做了很好的解释(它是免费的(基于阿帕奇服务),OSGi容器(还有更多的)有商业支持)。
因此,虽然我没有回答你们的具体问题,但我分享了我的一些经验,并希望这将对你们有所帮助。祝好运!
发布于 2012-05-30 04:18:19
使用-X选项运行Maven,它将使包插件打印它认为依赖树是什么
[DEBUG] Will bundle the following dependency tree
org.springframework:spring-remoting:jar:2.0.8:runtime
aopalliance:aopalliance:jar:1.0:compile
commons-httpclient:commons-httpclient:jar:3.0.1:compile
junit:junit:jar:3.8.1:compile
(commons-logging:commons-logging:jar:1.0.3:compile - omitted for conflict with 1.1)
commons-codec:commons-codec:jar:1.2:compile
commons-logging:commons-logging:jar:1.1:compile
log4j:log4j:jar:1.2.12:compile
logkit:logkit:jar:1.0.1:compile
avalon-framework:avalon-framework:jar:4.1.3:compile
(javax.servlet:servlet-api:jar:2.3:compile - omitted for conflict with 2.4)
hessian:hessian:jar:3.0.20:compile不幸的是,您无法调整项目的pom depdnencyManagement部分以删除“可选”依赖,因为maven-bundle-plugin忽略了这一点。
根据费利克斯-954的说法,它将访问所有可选的依赖项。我能提供的唯一建议是找到那些可选的工件,并确保Maven能够解决这些问题。
发布于 2011-06-22 01:46:11
在使其查找可选的依赖项。的maven-bundle-plugin的传递依赖项管理中存在一个bug (其中一些可能不存在)。我怀疑这就是当它试图拉进他的时候所发生的事情。
我将支持K.Claszen关于在springsource或fusesource上查找捆绑包的版本的想法,但是如果有您找不到的包,maven包插件提供了一个bundleall目标(目标部分对此进行了描述)。这个目标将导致包插件为应用程序的所有传递依赖项创建包。然后,您可以使用springsource/fusesource中找不到的那些。一旦您这样做了,您将不需要将jars嵌入到您的包中,这将使它们也可用于其他捆绑包。
您可能会遇到的一个警告是,需要部署捆绑包,以便在其依赖项之前不部署包。在过去,我曾使用Eclipse服务器来解决这个问题。它允许您将所有的包放在一个存储库中,并让服务器确定部署顺序。
https://stackoverflow.com/questions/6303035
复制相似问题