Maven创建Spring-DM工程

http://www.ops4j.org/projects/pax/construct/examples/spring-osgi.html该文章 是pax-construct 插件创建spring dm 的入门实例。下载里面的windows中运行的script运行就可以创建一个helloworld。现在来简单的介绍一下这个脚本。
   1)pax-create-project -g examples -a spring  创建一个名为spring的工程。具体命令介绍请看 上一篇文章maven创建osgi工程 http://201206262622.iteye.com/admin/blogs/1617796   。
   2) cd spring 。进入spring 目录
   3)设置spring dm 相关包的maven仓库地址 pax-add-repository -i com.springsource.repository.bundles.external -u http://repository.springsource.com/maven/bundles/external
   4)导入spring dm 的bundle。  pax-import-bundle -g org.springframework.osgi -a spring-osgi-extender -v 1.1.2 -- -DimportTransitive -DwidenScope
   5) 创建bundle。  pax-create-bundle -p org.example.service -- -Djunit
   6)创建一个bundle pax-create-bundle -p org.example.service -- -Djunit
   7) 创建一个spring bean  pax-create-bundle -p org.example.bean -- -Dspring -Djunit
   用equinox 代替默认的felix。 mvn clean install pax:provision "-Dframework=equinox"

  在运行时可能会报 Failed to load class "org.slf4j.impl.StaticLoggerBinder". pax错误。这是slf4j包版本不对导致,解决办法是将spring\provision 下面的pom文件中slf4j的版本改为1.6.0即可。
   如果运行中报Missing Constraint: Import-Package: org.apache.commons.logging; version="0.0.0"错误,解决办法是将apache的common log bundle选上。

猜你喜欢

转载自201206262622.iteye.com/blog/1617797