我通过修改我的代码将 Swagger Codegen 添加到我的 Eclipse 项目中pom.xml
直接归档:
<plugin>
<!--
Plugin that provides API-first development using swagger-codegen to
generate Spring-MVC endpoint stubs at compile time from a swagger definition file
-->
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${swagger-codegen-maven-plugin.version}</version>
<executions>
<execution>
<id>generate-swagger-javaclient</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/swagger/remote-api.json</inputSpec>
<language>java</language>
<apiPackage>com.myproj</apiPackage>
<modelPackage>com.myproj.model</modelPackage>
<generateSupportingFiles>true</generateSupportingFiles>
<generateApiTests>false</generateApiTests>
<configOptions>
<dateLibrary>java8</dateLibrary>
</configOptions>
<library>resttemplate</library>
</configuration>
</execution>
</executions>
</plugin>
如果我运行 Maven 更新或 Mavengenerate-sources
目标,我得到了 Eclipse 项目中生成的所有工件/target/generated-sources/swagger/src
folder.
但是,Eclipse 无法识别它们。我是否应该像普通人一样手动编辑 Eclipse 构建路径,或者 Eclipse 是否应该自动识别这个新的源文件夹?
在 Eclipse 4.9.0 (2018-09) 中,我必须添加 generated-sources 文件夹作为项目的源文件夹,如下所示:
- 打开“导航器”视图
- 浏览到 target/ generated-sources (或生成源的任何文件夹)。
- 右键单击该文件夹
- 单击“构建路径”->“用作源文件夹”
菜单树截图 https://i.stack.imgur.com/FF0xV.png
不解决“生命周期配置未涵盖插件执行”问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)