本文源自https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Startup_Project_Archetype Part1
一、环境信息:
Windows 10 + maven3.3.9 + JDK1.8,详细信息如下:
二、使用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:\CODE\odlexample\example1\example\karaf\target\assembly\bin>karafJava HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256M; support was removed in 8.0Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0Apache Karaf starting up. Press Enter to open the shell now...100% [========================================================================]Karaf started in 32s. Bundle stats: 294 active, 294 total ________ ________ .__ .__ .__ __ \_____ \ ______ ____ ____ \______ \ _____ ___.__.| | |__| ____ | |___/ |_ / | \\____ \_/ __ \ / \ | | \\__ \< | || | | |/ ___\| | \ __\ / | \ |_> > ___/| | \| ` \/ __ \\___ || |_| / /_/ > Y \ | \_______ / __/ \___ >___| /_______ (____ / ____||____/__\___ /|___| /__| \/|__| \/ \/ \/ \/\/ /_____/ \/Hit '' for a list of available commandsand '[cmd] --help' for help on a specific command.Hit ' ' or type 'system:shutdown' or 'logout' to shutdown OpenDaylight.opendaylight-user@root>
查看Example是否加载成功:
opendaylight-user@root>log:display | grep Example2017-07-25 17:54:25,488 | INFO | rint Extender: 1 | ExampleProvider | 208 - org.opendaylight.example.impl - 0.1.0.SNAPSHOT | ExampleProvider Session Initiatedopendaylight-user@root>
关闭OpenDaylight:
opendaylight-user@root>shutdown -fopendaylight-user@root>
三、问题记录
[INFO] --- maven-antrun-plugin:1.8:run (move-autowire-test) @ example-features ---[INFO] Executing tasksmain: [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:\CODE\odlexample\example1\example\features\target\surefire-reports------------------------------------------------------- T E S T S-------------------------------------------------------Running org.opendaylight.odlparent.featuretest.SingleFeatureTest
surefire-reports对应的报错信息为:
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)
原有的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