OSGI注意细节

关于第三方包地加入

eclipse: New-> Other -> Plug-in from existing JAR archives

导入到当前工程中

或者放在MANIFEST.MF的 Bundle-ClassPath: .,下,不过这样会造成jar打包时候有问题

最好的办法:建立一个bundle,让他的Bundle-ClassPath 加入全部的jar为其他的bundle提供服务

spring osgi bundle update操作并不管什么用,需要refresh操作

创建bundle最好的办法是:


下载,http://maven.apache.org/

环境变量 ,添加 MAVEN_HOME : D:\java\apache-maven-2.0.9\,

在path中加入D:\java\apache-maven-2.0.9\bin

如果安装老是失败,建议用 mvn clean install,

如果出现下面的错误,可以忽略
[ERROR] BUILD ERROR
[INFO] ————————————————————————
[INFO] Cannot execute mojo: clean. It requires a project with an existing pom.xm
l, but the build is not using one.

新建一个空的目录,如D:\test\osgi,打开cmd并到刚才建的目录下执行:

mvn archetype:create -DarchetypeGroupId=org.springframework.osgi -DarchetypeArtifactId=spring-osgi-bundle-archetype -DarchetypeVersion=1.1.0 -DgroupId=org.foo -DartifactId=org.foo.my-springdm-bundle -Dversion=0.1

注意是这一行命令, 项目框架用的是spring-osgi-bundle-archetype,如果看到一个新建目录org.foo.my-springdm-bundle,表示已经建好了一个空项目 :-)。

进入项目的根目录,用下面的命令生成MANIFEST.MF file 和 META-INF目录。

cd D:\test\osgi\org.foo.my-springdm-bundle

mvn package
mvn org.apache.felix:maven-bundle-plugin:manifest

最后的生成结果

* Packaged as an OSGi bundle
* META-INF/MANIFEST.MF automatically generated
* src/main/java/<package> public package automatically exported
* src/main/java/<package>/internal private package
* src/main/resources/META-INF/spring/bundle-context.xml is a spring configuration file that defines the simple bean.
* src/main/resources/META-INF/spring/bundle-context-osgi.xml is a spring configuration file ready for you to add bean definitions from the osgi namespace (services, references etc.).
* .project, .classpath, and build.properties files created to enable use of this project directly inside eclipse as a PDE plugin project
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值