zoukankan      html  css  js  c++  java
  • 从零开始学OpenDaylight(碳版本)之二:使用Archetype构建项目

    本文源自https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Startup_Project_Archetype Part1

    一、环境信息:

         Windows 10 + maven3.3.9 + JDK1.8,详细信息如下:     

    <properties>
        <property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
        <property name="sun.boot.library.path" value="C:Program FilesJavajdk1.8.0_121jrein"/>
        <property name="java.vm.version" value="25.121-b13"/>
        <property name="java.vm.vendor" value="Oracle Corporation"/>
        <property name="maven.multiModuleProjectDirectory" value="D:CODEodlexampleexample1example"/>
        <property name="java.vendor.url" value="http://java.oracle.com/"/>
        <property name="path.separator" value=";"/>
        <property name="guice.disable.misplaced.annotation.check" value="true"/>
        <property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
        <property name="file.encoding.pkg" value="sun.io"/>
        <property name="user.script" value=""/>
        <property name="user.country" value="CN"/>
        <property name="sun.java.launcher" value="SUN_STANDARD"/>
        <property name="sun.os.patch.level" value=""/>
        <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
        <property name="user.dir" value="D:CODEodlexampleexample1example"/>
        <property name="java.runtime.version" value="1.8.0_121-b13"/>
        <property name="java.awt.graphicsenv" value="sun.awt.Win32GraphicsEnvironment"/>
        <property name="java.endorsed.dirs" value="C:Program FilesJavajdk1.8.0_121jrelibendorsed"/>
        <property name="os.arch" value="amd64"/>
        <property name="java.io.tmpdir" value="C:Users
    ootAppDataLocalTemp"/>
        <property name="line.separator" value="&#10;"/>
        <property name="java.vm.specification.vendor" value="Oracle Corporation"/>
        <property name="user.variant" value=""/>
        <property name="os.name" value="Windows 10"/>
        <property name="classworlds.conf" value="D:softapache-maven-3.3.9in..inm2.conf"/>
        <property name="sun.jnu.encoding" value="GBK"/>
        <property name="java.library.path" value="C:Program FilesJavajdk1.8.0_121in;C:WindowsSunJavain;C:Windowssystem32;C:Windows;C:ProgramDataOracleJavajavapath;C:Program FilesVanDyke SoftwareClients;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT;C:Program FilesIntelIntel(R) Management Engine ComponentsIPT;C:Program FilesIntelWiFiin;C:Program FilesCommon FilesIntelWirelessCommon;D:softapache-maven-3.3.9in;C:Program FilesJavajdk1.8.0_121in;C:Program FilesJavajdk1.8.0_121jrein;C:Users
    ootAppDataLocalMicrosoftWindowsApps;;."/>
        <property name="java.specification.name" value="Java Platform API Specification"/>
        <property name="java.class.version" value="52.0"/>
        <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
        <property name="maven.test.failure.ignore" value="true"/>
        <property name="os.version" value="10.0"/>
        <property name="user.home" value="C:Users
    oot"/>
        <property name="user.timezone" value="Asia/Shanghai"/>
        <property name="java.awt.printerjob" value="sun.awt.windows.WPrinterJob"/>
        <property name="java.specification.version" value="1.8"/>
        <property name="file.encoding" value="GBK"/>
        <property name="user.name" value="root"/>
        <property name="java.class.path" value="D:softapache-maven-3.3.9in..ootplexus-classworlds-2.5.2.jar"/>
        <property name="java.vm.specification.version" value="1.8"/>
        <property name="sun.arch.data.model" value="64"/>
        <property name="java.home" value="C:Program FilesJavajdk1.8.0_121jre"/>
        <property name="sun.java.command" value="org.codehaus.plexus.classworlds.launcher.Launcher clean install -Dmaven.test.failure.ignore=true"/>
        <property name="java.specification.vendor" value="Oracle Corporation"/>
        <property name="user.language" value="zh"/>
        <property name="awt.toolkit" value="sun.awt.windows.WToolkit"/>
        <property name="java.vm.info" value="mixed mode"/>
        <property name="java.version" value="1.8.0_121"/>
        <property name="java.ext.dirs" value="C:Program FilesJavajdk1.8.0_121jrelibext;C:WindowsSunJavalibext"/>
        <property name="sun.boot.class.path" value="C:Program FilesJavajdk1.8.0_121jrelib
    esources.jar;C:Program FilesJavajdk1.8.0_121jrelib
    t.jar;C:Program FilesJavajdk1.8.0_121jrelibsunrsasign.jar;C:Program FilesJavajdk1.8.0_121jrelibjsse.jar;C:Program FilesJavajdk1.8.0_121jrelibjce.jar;C:Program FilesJavajdk1.8.0_121jrelibcharsets.jar;C:Program FilesJavajdk1.8.0_121jrelibjfr.jar;C:Program FilesJavajdk1.8.0_121jreclasses"/>
        <property name="sun.stderr.encoding" value="ms936"/>
        <property name="java.vendor" value="Oracle Corporation"/>
        <property name="maven.home" value="D:softapache-maven-3.3.9in.."/>
        <property name="file.separator" value=""/>
        <property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/>
        <property name="sun.cpu.endian" value="little"/>
        <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
        <property name="sun.stdout.encoding" value="ms936"/>
        <property name="sun.desktop" value="windows"/>
        <property name="sun.cpu.isalist" value="amd64"/>
      </properties>

    二、使用Archetype构建项目过程     

    1. 使用Archetype构建基于openDaylight-carbon版本的项目

    mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/opendaylight.release -DarchetypeCatalog=remote -DarchetypeVersion=1.3.0-Carbon

     并在后续的提示框中输入相关的值:

     生成的目录结构树如下所示(tree命令)

    example
        ├─api
        │  └─src
        │      └─main
        │          └─yang
        ├─artifacts
        ├─cli
        │  └─src
        │      └─main
        │          ├─java
        │          │  └─org
        │          │      └─opendaylight
        │          │          └─example
        │          │              └─cli
        │          │                  ├─api
        │          │                  ├─commands
        │          │                  └─impl
        │          └─resources
        │              └─org
        │                  └─opendaylight
        │                      └─blueprint
        ├─features
        │  └─src
        │      └─main
        │          └─features
        ├─impl
        │  └─src
        │      ├─main
        │      │  ├─java
        │      │  │  └─org
        │      │  │      └─opendaylight
        │      │  │          └─example
        │      │  │              └─impl
        │      │  └─resources
        │      │      └─org
        │      │          └─opendaylight
        │      │              └─blueprint
        │      └─test
        │          └─java
        ├─it
        │  └─src
        │      └─test
        │          └─java
        │              └─org
        │                  └─opendaylight
        │                      └─example
        │                          └─it
        ├─karaf
        └─src
            ├─main
            │  └─resources
            └─site

     2. 执行 mvn clean install -Dmaven.test.failure.ignore=true,成功后的信息如下:

      3. 进入到 karaf.bat 目录,启动karaf

    D:CODEodlexampleexample1examplekaraf	argetassemblyin>karaf
    Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256M; support was removed in 8.0
    Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
    Apache Karaf starting up. Press Enter to open the shell now...
    100% [========================================================================]
    
    Karaf started in 32s. Bundle stats: 294 active, 294 total
    
        ________                       ________                .__  .__       .__     __
        \_____   ______   ____   ____ \______  _____  ___.__.|  | |__| ____ |  |___/  |_
         /   |   \____ \_/ __  /     |    |  \__  <   |  ||  | |  |/ ___|  |     __
        /    |      |_> >  ___/|   |  |    `   / __ \___  ||  |_|  / /_/  >   Y    |
        \_______  /   __/ \___  >___|  /_______  (____  / ____||____/__\___  /|___|  /__|
                /|__|        /     /        /     //            /_____/      /
    
    
    Hit '<tab>' for a list of available commands
    and '[cmd] --help' for help on a specific command.
    Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown OpenDaylight.
    
    opendaylight-user@root>

    查看Example是否加载成功:

    opendaylight-user@root>log:display | grep Example
    2017-07-25 17:54:25,488 | INFO  | rint Extender: 1 | ExampleProvider                  | 208 - org.opendaylight.example.impl - 0.1.0.SNAPSHOT | ExampleProvider Session Initiated
    opendaylight-user@root>

     关闭OpenDaylight:

    opendaylight-user@root>shutdown -f
    opendaylight-user@root>

    三、问题记录

    [INFO] --- maven-antrun-plugin:1.8:run (move-autowire-test) @ example-features ---
    [INFO] Executing tasks
    
    main:
         [echo] Moving autowire.xml to org/opendaylight/blueprint
    [INFO] Executed tasks
    [INFO]
    [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ example-features ---
    [INFO] Surefire report directory: D:CODEodlexampleexample1examplefeatures	argetsurefire-reports
    
    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running org.opendaylight.odlparent.featuretest.SingleFeatureTest

     surefire-reports对应的报错信息为:

      <testcase name="installFeature" classname="installFeature(org.opendaylight.odlparent.featuretest.SingleFeatureTest)[repoUrl: file:/D:/CODE/odlexample/example1/example/features/target/classes/features.xml, Feature: odl-example-api 0.1.0-SNAPSHOT]" time="185.064">
        <error message="ffaf2fde-a115-4b78-a169-524b099119b6" type="java.rmi.NotBoundException">java.rmi.NotBoundException: ffaf2fde-a115-4b78-a169-524b099119b6
        at sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:209)
        at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
        at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:450)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
        at sun.rmi.transport.Transport$1.run(Transport.java:200)
        at sun.rmi.transport.Transport$1.run(Transport.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
        at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276)
        at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:379)
        at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        at org.ops4j.pax.exam.rbc.client.intern.RemoteBundleContextClientImpl.getRemoteBundleContext(RemoteBundleContextClientImpl.java:242)
        at org.ops4j.pax.exam.rbc.client.intern.RemoteBundleContextClientImpl.waitForState(RemoteBundleContextClientImpl.java:211)
        at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.waitForState(KarafTestContainer.java:607)
        at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.startKaraf(KarafTestContainer.java:241)
        at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.start(KarafTestContainer.java:181)
        at org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactor.invoke(AllConfinedStagedReactor.java:79)
        at org.ops4j.pax.exam.junit.impl.ProbeRunner$2.evaluate(ProbeRunner.java:267)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.ops4j.pax.exam.junit.impl.ProbeRunner.run(ProbeRunner.java:98)
        at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:93)
        at org.opendaylight.odlparent.featuretest.PerFeatureRunner.run(PerFeatureRunner.java:72)
        at org.opendaylight.odlparent.featuretest.PerRepoTestRunner.runChild(PerRepoTestRunner.java:143)
        at org.opendaylight.odlparent.featuretest.PerRepoTestRunner.runChild(PerRepoTestRunner.java:26)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
    </error>
        <system-out><![CDATA[[sys.out] About to run test: org.opendaylight.odlparent.featuretest.SingleFeatureTest[repoUrl: file:/D:/CODE/odlexample/example1/example/features/target/classes/features.xml, Feature: odl-example-api 0.1.0-SNAPSHOT]
    ]]></system-out>
        <system-err><![CDATA[SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/D:/repository/org/apache/karaf/org.apache.karaf.client/3.0.8/org.apache.karaf.client-3.0.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/D:/repository/org/ops4j/pax/logging/pax-logging-api/1.8.4/pax-logging-api-1.8.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/D:/repository/org/slf4j/slf4j-simple/1.7.21/slf4j-simple-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
    2923 [main] ERROR org.opendaylight.odlparent.featuretest.PerRepoTestRunner - getClass().getClassLoader().getResource("feature.xml") returned null
    3094 [main] ERROR org.opendaylight.odlparent.featuretest.PerRepoTestRunner - getClass().getClassLoader().getResource("feature.xml") returned null
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    Unrecognized option: -3
    ]]></system-err>

    原有的mvn命令为:mvn clean install --Dmaven.test.skip=true,报上面的错误后,将mvn命令调整为:mvn clean install -Dmaven.test.failure.ignore=true,surefire-reports仍有报错信息(消耗一定的时间),但最终会跳过去。

    附:

    -DskipTests,不执行测试用例,但编译测试用例类生成相应的class文件至target/test-classes下。

    -Dmaven.test.skip=true,不执行测试用例,也不编译测试用例类。

    -Dmaven.test.failure.ignore=true,即使测试出现失败用例,仍然希望能继续构建项目

    参考链接:http://www.cnblogs.com/pixy/p/4718176.html

  • 相关阅读:
    2020.02.28 【ABAP随笔】- EXCEL批导程式3
    2020.02.27 【ABAP随笔】- EXCEL批导程式2
    2020.02.26 【ABAP随笔】- EXCEL批导程式1
    2020.02.24 【ABAP随笔】- EXCEL常见操作笔记 1
    2020.02.15 【ABAP随笔】- 物料主数据增强
    2020.01.14 【ABAP随笔】-程序优化笔记
    2020.01.11 【ABAP随笔】获取标准报表数据(MB52)数据进行客制ALV
    2020.01.11 【ABAP随笔】SM30常见增强操作-自动带描述等
    2020.01.10 【ABAP随笔】ALV上的下拉框
    Linux资源监控命令/工具(调试)
  • 原文地址:https://www.cnblogs.com/FrankZhou2017/p/7235167.html
Copyright © 2011-2022 走看看