首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过swagger-codegen-maven-plugin在pom中生成maven-jar-plugin 3.1.2版本

如何通过swagger-codegen-maven-plugin在pom中生成maven-jar-plugin 3.1.2版本
EN

Stack Overflow用户
提问于 2019-07-16 09:25:04
回答 1查看 1.2K关注 0票数 1

我正在使用swagger-codegen-maven-plugin 2.4.7版本来生成项目。它生成maven-jar-plugin2.6版本,但我需要3.1.2版本。

有没有一种方法来生成自定义插件版本?

生成的pom.xml:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <executions> <execution> <goals> <goal>jar</goal> <goal>test-jar</goal> </goals> </execution> </executions> <configuration> </configuration> </plugin>

通缉pom.xml:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.1.2</version> <executions> <execution> <goals> <goal>test-jar</goal> </goals> </execution> </executions> <configuration> </configuration> </plugin>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-16 13:06:24

Swagger的输出是基于胡子模板。例如,Java + jersey2库的pom.xml模板可在这里获得:

https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache

Swagger允许您使用自定义模板覆盖内置模板。您可以这样做:

  1. 在项目中创建一个文件夹(例如,codegen-templates)。
  2. pom.mustache模板从此链接下载到该文件夹。 https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache
  3. 编辑下载的pom.mustache并根据需要更新maven-jar-plugin版本和配置。
  4. pom.xml中,在<templateDirectory>参数中指定codegen-templates文件夹的路径: io.swagger swagger-codegen-maven-plugin 2.4.7生成https://petstore.swagger.io/v2/swagger.yaml java jersey2 ${project.basedir}/codegen-模板

现在Swagger将根据您的自定义pom.xml模板生成pom.mustache

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57054071

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档