使用 swagger codegen 插件通过几个 yaml 文件生成代码

我有几个swagger yaml文件,我想在编译时使用maven生成代码。


这是我的代码:


 <plugins>

        <plugin>

            <groupId>io.swagger</groupId>

            <artifactId>swagger-codegen-maven-plugin</artifactId>

            <version>2.3.1</version>

            <executions>

                <execution>

                    <goals>

                        <goal>generate</goal>

                    </goals>

                    <configuration>

                        <inputSpec>${project.basedir}/src/main/resources/*.yaml</inputSpec>

                        <language>java</language>

                        <configOptions>

                            <sourceFolder>src/gen/java/main</sourceFolder>

                        </configOptions>

                    </configuration>

                </execution>

            </executions>

        </plugin>

    </plugins>

我正在尝试获取资源中的所有 yaml 文件作为输入:


<inputSpec>${project.basedir}/src/main/resources/*.yaml</inputSpec>

但这不起作用,我遇到了这个错误:


failed to read resource listing

java.io.FileNotFoundException: C:\Projets\www\codegen\src\main\resources\*.yaml (La syntaxe du nom de fichier, de répertoire ou de volume est incorrecte)

任何想法 ?


炎炎设计
浏览 223回答 1
1回答

隔江千里

我的问题通过使用多次执行得到解决,如下所示:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>io.swagger</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>swagger-codegen-maven-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <version>2.4.5</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <executions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <id>a</id> .....&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <id>b</id> .....&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <id>c</id> .....&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</executions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </plugin>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java