我将 Quarkus 与 Kotlin 结合使用,并尝试使用此 Quarkus 扩展生成 Rest 客户端https://github.com/quarkiverse/quarkus-openapi-generator。
我将依赖项和提到的插件包含到 pom.xml 中
<dependency>
<groupId>io.quarkiverse.openapi.generator</groupId>
<artifactId>quarkus-openapi-generator</artifactId>
<version>0.9.0</version>
</dependency>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
编译时,所有内容都会正确生成为
target/openapi/quarkus/clients_json/api/DefaultApi.java
但是,当尝试导入
DefaultApi
时,它会抛出找不到该类的错误。
我已经尝试了以下帖子中的建议maven无法在编译阶段的生成源中添加文件并包含
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/gen-java</source><!-- adjust folder name to your needs -->
</sources>
</configuration>
</execution>
</executions>
</plugin>
也进入 pom.xml,但它没有做任何事情。
有谁知道如何更改 Quarkus 生成的 OpenApi 文件的输出目录?
仅供参考:
我做了以下操作,并且成功了
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/openapi</source>
<source>src/gen/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
虽然我的回答很简短,并且您设法解决了您的问题 - 很多其他人也遇到了生成的源未在 Eclipse 中显示导入或自动完成的问题,我尝试了建议,例如检查自动设置在编辑器中完成,关闭项目并重新打开它。检查并调整属性下的源设置。在我完全关闭 Eclipse 并重新打开它之前,没有任何效果。
只是想将其放在这里,以防其他人遇到类似的问题!