M H*_*Hot 6 maven spring-boot openapi openapi-generator
我使用 OpenApi 3.0 和 maven 插件openapi-generator-maven-plugin来生成我的 api + 对象。
这是我的 Maven 配置:
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/BookingService.yaml</inputSpec>
<generatorName>spring</generatorName>
<modelPackage>${clientPackage}.model</modelPackage>
<invokerPackage>${clientPackage}.invoker</invokerPackage>
<apiPackage>${clientPackage}.api</apiPackage>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<configOptions>
<delegatePattern>true</delegatePattern>
</configOptions>
</configuration>
</execution>
Run Code Online (Sandbox Code Playgroud)
它按预期工作,但它也会生成我不想要的测试。正如您在我的配置中看到的,我禁用了 Api 测试 + 模型测试的测试。
这些测试的编译失败,因为构建目标文件夹中的“无法解析符号‘SpringBootTest’”...
这些测试没有任何意义,我该如何禁用它们?
请注意,这是一个解决方法。最好获得一个不生成此测试用例的属性,但目前这似乎有效......
将此 Maven 插件添加到您的 pom.xml 中
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- remove the unwanted generated testcases by the spring generator of openapi -->
<delete dir="${project.build.directory}/generated-sources/openapi/src/test" />
</target>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
在流程源阶段生成源后,它将删除整个测试包
归档时间: |
|
查看次数: |
4072 次 |
最近记录: |