无法使用Yangtools从yang文件生成pojos

时间:2018-07-16 14:00:24

标签: opendaylight

我正在尝试根据此guide使用OpenDaylight从Yang文件生成Pojo。 我从OpenDaylight github克隆了Yangtools,并使用mvn clean install

构建了该项目

我已将以下内容添加到我的pom中:

<plugin>
           <groupId>org.opendaylight.yangtools</groupId>
           <artifactId>yang-maven-plugin</artifactId>
           <version>2.0.8-SNAPSHOT</version>
           <executions>
               <execution>
                   <goals>
                       <goal>generate-sources</goal>
                   </goals>
                   <configuration>
                       <!-- directory containing yang files to parse and generate code -->
                       <yangFilesRootDir>src/main/yang</yangFilesRootDir>
                       <codeGenerators>
                           <generator>
                               <codeGeneratorClass>
                                   org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl
                               </codeGeneratorClass>
                               <!-- directory into which generated files will be placed -->
                               <outputBaseDir>
                                   target/generated-sources
                               </outputBaseDir>
                           </generator>
                       </codeGenerators>
                       <!-- if true, plugin will search for yang files also in dependent projects -->
                       <inspectDependencies>true</inspectDependencies>
                   </configuration>
               </execution>
           </executions>
           <dependencies>
               <dependency>
                   <groupId>org.opendaylight.yangtools</groupId>
                   <artifactId>maven-sal-api-gen-plugin</artifactId>
                   <version>0.7.4-Lithium-SR4</version>
                   <type>jar</type>
               </dependency>
           </dependencies>
       </plugin>

但是我无法生成源。我收到以下错误:

[ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:2.0.8-SNAPSHOT:generate-sources (default) on project odl-poc: Execution default of goal org.opendaylight.yangtools:yang-maven-plugin:2.0.8-SNAPSHOT:generate-sources failed: An API incompatibility was encountered while executing org.opendaylight.yangtools:yang-maven-plugin:2.0.8-SNAPSHOT:generate-sources: java.lang.AbstractMethodError: Method org/opendaylight/yangtools/maven/sal/api/gen/plugin/CodeGeneratorImpl.generateSources(Lorg/opendaylight/yangtools/yang/model/api/SchemaContext;Ljava/io/File;Ljava/util/Set;Ljava/util/function/Function;)Ljava/util/Collection; is abstract

我在做什么错了?

1 个答案:

答案 0 :(得分:3)

看起来像版本不兼容-您引用的是yang-maven-plugin版本2.0.8-SNAPSHOT,它是当前未发布的master分支,而依赖项是maven-sal-api-gen-plugin版本0.7.4-Lithium -SR4,就像5个主要版本之前一样,并且已经过时了。