我在 /opt/odl_l3vpn/dave/api/src/main/yang 中安装了 OpenDayLight Boron-SR3 和一个测试 YANG 文件。
module DaveTest {
namespace "urn:opendaylight:params:xml:ns:DaveTest";
prefix dm;
import "ietf-inet-types" {
prefix ietf-yang;
}
description "Dave testing file";
revision "2017-04-17" {
description "Initial version.";
}
container testing-vars {
list test-list {
key "vpn-transaction-id";
unique "vpn-transaction-id";
leaf vpn-transaction-id {
type string;
description "Generated for the model.";
}
leaf vpn-id {
type string;
description "VPN ID for the VPN.";
}
}
}
}
当我使用“mvn clean install -nsu”编译文件时,出现错误:
[错误] 无法执行目标 org.opendaylight.yangtools:yang-maven-plugin:1.0.3-Boron-SR3:generate-sources (binding) on project dave-api: yang-to-sources: Unable to parse yang 文件来自 /opt/odl_l3vpn/dave/api/src/main/yang:未找到导入的模块 [ietf-inet-types]。[在 META-INF/yang/DaveTest.yang:6:4]
下面的全栈:
[ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:1.0.3-Boron-SR3:generate-sources (binding) on project dave-api: yang-to-sources: Unable to parse yang files from /opt/odl_l3vpn/dave/api/src/main/yang: Imported module [ietf-inet-types] was not found. [at META-INF/yang/DaveTest.yang:6:8] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:1.0.3-Boron-SR3:generate-sources (binding) on project dave-api: yang-to-sources: Unable to parse yang files from /opt/odl_l3vpn/dave/api/src/main/yang
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: yang-to-sources: Unable to parse yang files from /opt/odl_l3vpn/dave/api/src/main/yang
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.processYang(YangToSourcesProcessor.java:222)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.execute(YangToSourcesProcessor.java:95)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.conditionalExecute(YangToSourcesProcessor.java:118)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesMojo.execute(YangToSourcesMojo.java:119)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: Imported module [ietf-inet-types] was not found. [at META-INF/yang/DaveTest.yang:6:8]
at org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException.throwIf(InferenceException.java:47)
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.ImportStatementDefinition$1.prerequisiteFailed(ImportStatementDefinition.java:116)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.ModifierImpl.failModifier(ModifierImpl.java:93)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.SourceSpecificContext.failModifiers(SourceSpecificContext.java:294)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.addSourceExceptions(BuildGlobalContext.java:268)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.completePhaseActions(BuildGlobalContext.java:343)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.buildEffective(BuildGlobalContext.java:200)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor$BuildAction.buildEffective(CrossSourceStatementReactor.java:128)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor$BuildAction.buildEffective(CrossSourceStatementReactor.java:145)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.processYang(YangToSourcesProcessor.java:191)
... 25 more
我的 pom.xml 在主目录 /opt/odl_l3vpn/dave 中。我在 'build' 下添加了 'ietf-inet-types 依赖项,但由于我对 pom 文件缺乏了解,可能将其放置在错误的位置。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<dependencies>
<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>ietf-inet-types</artifactId>
<version>2010.09.24.8.5-SNAPSHOT</version>
<type>bundle</type>
</dependency>
</dependencies>
</plugin>
</plugins>
添加依赖项以便我的 YANG 文件可以编译的合适位置在哪里?或者你能指出我正确的方向吗?提前致谢。