我使用 maven-codegen-plugin 只是为了从我的 yml 文件生成 Controller 和模型文件的接口(interface)。这是一个 java spring-boot 项目。
插件配置:
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.4.10</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api.yml</inputSpec>
<output>${project.build.directory}/generated-sources/swagger</output>
<language>spring</language>
<configOptions>
<java8>true</java8>
<interfaceOnly>true</interfaceOnly>
<dateLibrary>java</dateLibrary>
</configOptions>
<modelPackage>${project.groupId}.blabla.model</modelPackage>
<apiPackage>${project.groupId}.blabla.controller</apiPackage>
</configuration>
</execution>
</executions>
</plugin>
重点是在我的 target/generated-sources 目录/swagger 中生成了很多我不需要的文件,例如:
- .swagger-codegen/版本
- .swagger-codegen-ignore
- pom-xml
- 自述文件
我只需要的文件是在 src/main/java 中生成的文件....基本上是模型和 Controller 包。
如何配置插件不生成此类文件?
提前致谢
最佳答案
您应该添加以下代码:
<configuration>
<skipOverwrite>true</skipOverwrite>
</configuration>
避免pom.xml
和readme.md
被覆盖
以及 .gitIgnore
下的其余文件
关于spring-boot - Maven Swagger swagger-codegen-plugin 只生成模型和 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59303753/