CodeGenerator的OpenDaylight Yangtools codeGeneratorClass不能为空

时间:2018-07-22 07:12:41

标签: opendaylight

我能够使用opendaylight yangtools从Yang文件生成Pojos。但是在mvn generate-sources或mvn clean build生成完成后,我不断收到此错误:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.816 s
[INFO] Finished at: 2018-07-22T10:09:59+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:2.0.8-SNAPSHOT:generate-sources (default) on project odl-yang-generator-poc: Execution default of goal org.opendaylight.yangtools:yang-maven-plugin:2.0.8-SNAPSHOT:generate-sources failed: codeGeneratorClass for CodeGenerator cannot be null

Caused by: java.lang.NullPointerException: codeGeneratorClass for CodeGenerator cannot be null
    at com.google.common.base.Preconditions.checkNotNull (Preconditions.java:900)
    at org.opendaylight.yangtools.yang2sources.plugin.ConfigArg$CodeGeneratorArg.check (ConfigArg.java:71)
    at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.instantiateGenerators (YangToSourcesProcessor.java:219)
    at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.conditionalExecute (YangToSourcesProcessor.java:135)
    at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesMojo.execute (YangToSourcesMojo.java:123)

这是我的pom:

<parent>
        <groupId>org.opendaylight.mdsal</groupId>
        <artifactId>binding-parent</artifactId>
        <version>0.13.0-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <build>
    <plugins>
            <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>
                            <yangFilesRootDir>src/main/yang</yangFilesRootDir>
                                <codeGenerators>
                                <generator>
                                        org.opendaylight.mdsal.maven.sal.api.gen.plugin.CodeGeneratorImpl
                                    <outputBaseDir>
                                        target/generated-sources
                                    </outputBaseDir>
                                </generator>
                                </codeGenerators>
                            <inspectDependencies>true</inspectDependencies>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.opendaylight.mdsal</groupId>
                        <artifactId>maven-sal-api-gen-plugin</artifactId>
                        <version>0.13.0-SNAPSHOT</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

显然是因为生成了文件,所以找到了生成器。 是什么导致异常?

1 个答案:

答案 0 :(得分:2)

org.opendaylight.mdsal.maven.sal.api.gen.plugin.CodeGeneratorImpl不正确-它应该是org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl。

但是,您是从绑定父母派生pom的,所以您根本不需要重新定义yang-maven插件,因为它已经由绑定父母定义/提供。