通过直接修改pom.xml文件,我将Swagger添加到了Eclipse项目中:
<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 update或Maven generate-sources目标,我将获得在/target/generated-sources/swagger/src项目的/target/generated-sources/swagger/src文件夹中生成的所有伪文件。
但是,Eclipse不认识它们。我应该像普通用户一样手动编辑Eclipse构建路径,还是Eclipse应该自动识别这个新的源文件夹?
发布于 2018-08-29 06:51:24
如果这个插件本身不支持,您可以使用build-helper-maven-plugin将生成的源代码添加到构建路径中。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/target/generated-sources/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>发布于 2019-05-14 09:19:29
在Eclipse4.9.0 (2018-09)中,我不得不将generated文件夹添加为项目的源文件夹,如下所示:
无法解决“生命周期配置未涉及的插件执行”问题。
发布于 2019-07-19 12:18:03
Ctrl+shift+R
打开“打开资源”对话框。除了消息行‘输入资源名称.’有一个下降的选项。当你点击它时,你会得到“显示状态”、“显示派生源”等选项。
您必须确保选中了“显示派生源”。Eclipse也将开始显示自命不凡的工件。
https://stackoverflow.com/questions/48293364
复制相似问题