zoukankan      html  css  js  c++  java
  • 《深入理解OSGi:Equinox原理、应用与最佳实践》笔记_2_建立开发环境

    本文对应书本5.1.3的内容

     书本中通过CVS下载的源码

    但是笔者实践的时候发现无法下载...地址已经失效了(也许是笔者的失误输错地址所致)

    可以用git下载 

    地址是:

    http://git.eclipse.org/c/equinox

    进入需要下载的组件的页面 在最下面有git clone的地址

    http://git.eclipse.org/c/equinox/rt.equinox.framework.git/ 写道
    Clone
    git://git.eclipse.org/gitroot/equinox/rt.equinox.framework.git
    ssh://git.eclipse.org/gitroot/equinox/rt.equinox.framework.git
    http://git.eclipse.org/gitroot/equinox/rt.equinox.framework.git

    在eclipse中下载很简单 打开git仓库的面板 输入地址即可



     

    选择需要的导入就可以了



     

    接下来配置run configuration

    和书中一样这里截图略过:



     

     

    接下来是dev.properties文件和conf.ini文件 如下:

    Properties代码  收藏代码
    1. BundleHelloworld=bin   
    2. org.eclipse.osgi=bin  
    3. @ignoredot@=true  

     conf.ini:

    Java代码  收藏代码
    1. #和书中相比多了很多其他的bundle 这些是启动console必需的  
    2. osgi.bundles=reference:file:G:/osgi_workbench/test/BundleHelloworld@start,reference:file:E:/eclipseForEE/osgi_test/eclipse/plugins/org.apache.felix.gogo.command_0.10.0.v201209301215.jar@start,reference:file:E:/eclipseForEE/osgi_test/eclipse/plugins/org.apache.felix.gogo.runtime_0.10.0.v201209301036.jar@start,reference:file:E:/eclipseForEE/osgi_test/eclipse/plugins/org.apache.felix.gogo.shell_0.10.0.v201212101605.jar@start,reference:file:E:/eclipseForEE/osgi_test/eclipse/plugins/org.eclipse.equinox.console_1.0.100.v20130429-0953.jar@start  
    3.   
    4. osgi.bundles.defaultStartLevel=4  
    5.   
    6. osgi.framework=file:H:/repository/git/rt.equinox.framework/rt.equinox.framework/bundles/org.eclipse.osgi  
    7.   
    8. #osgi.framework=file/:E:/eclipseForEE/osgi_test/eclipse/plugins/org.eclipse.osgi_3.9.1.v20130814-1242.jar  
    9.   
    10. eclipse.ignoreApp=true  
    11.   
    12. osgi.noShutdown=true  
    13.   
    14. osgi.console=  

    有关以上比书本上多的那几个jar 看:

    http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fconsole_shell.htm

    可以直接用eclipse的plugins文件夹下的

    没有那几个jar BundleHelloworld可以运行 但不会出现 osgi>

    并且会有错误信息 如下:

    log 写道
    !SESSION 2013-12-23 13:33:04.949 -----------------------------------------------
    eclipse.buildId=unknown
    java.version=1.7.0_40
    java.vendor=Oracle Corporation
    BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN
    Command-line arguments: -dev file:E:/eclipseForEE/osgi_test/config/dev.properties

    !ENTRY org.eclipse.osgi 4 0 2013-12-23 13:33:05.347
    !MESSAGE Could not find bundle: false
    !STACK 0
    org.osgi.framework.BundleException: Could not find bundle: false
    at org.eclipse.core.runtime.internal.adaptor.ConsoleManager.checkForConsoleBundle(ConsoleManager.java:58)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:323)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:222)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

    注意bundle中的文件前应该有 reference:file: 不然会提示找不到

    在以上新建的java application中点run 会出现以下信息就代表运行成功:



     

  • 相关阅读:
    快速免费用宝塔面板加开源小程序商城源码搭建自己的商城程序
    小程序商城,到底是购买源码好还是直接使用SaaS平台好?
    51单片机串口通信的注记
    关于vi 分屏的一些指令
    偶遇bash 的while read line 的问题
    centos 6 设置无密码登录ssh 不成功问题
    关于js框架 dwz 与 yii的的分页 以及筛选的结合
    完美解决百度地图MarkerClusterer 移动地图时,Marker 的Label 丢失的问题
    微信小程序购物商城系统开发系列-目录结构
    微信小程序支付步骤
  • 原文地址:https://www.cnblogs.com/timssd/p/5100905.html
Copyright © 2011-2022 走看看