[Java][Spring] Fix #14362 when useSpringBoot3=true, then useJakartaEe=true (#14373)

This commit is contained in:
Paul Parenko 2023-01-12 12:54:42 +01:00 committed by GitHub
parent 076b88429e
commit c2c91e2d2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -95,7 +95,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true| |useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false| |useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useOptional|Use Optional container for optional parameters| |false| |useOptional|Use Optional container for optional parameters| |false|
|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports).| |false| |useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false|
|useSpringController|Annotate the generated API as a Spring Controller| |false| |useSpringController|Annotate the generated API as a Spring Controller| |false|
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true| |useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|useTags|use tags for creating interface and controller classnames| |false| |useTags|use tags for creating interface and controller classnames| |false|

View File

@ -88,7 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true| |useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false| |useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useOptional|Use Optional container for optional parameters| |false| |useOptional|Use Optional container for optional parameters| |false|
|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports).| |false| |useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false|
|useSpringController|Annotate the generated API as a Spring Controller| |false| |useSpringController|Annotate the generated API as a Spring Controller| |false|
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true| |useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|useTags|use tags for creating interface and controller classnames| |false| |useTags|use tags for creating interface and controller classnames| |false|

View File

@ -241,7 +241,7 @@ public class SpringCodegen extends AbstractJavaCodegen
"Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies", "Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies",
useSwaggerUI)); useSwaggerUI));
cliOptions.add(CliOption.newBoolean(USE_SPRING_BOOT3, cliOptions.add(CliOption.newBoolean(USE_SPRING_BOOT3,
"Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports).", "Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.",
useSpringBoot3)); useSpringBoot3));
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application."); supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application.");
@ -473,6 +473,8 @@ public class SpringCodegen extends AbstractJavaCodegen
if (AnnotationLibrary.SWAGGER1.equals(getAnnotationLibrary())) { if (AnnotationLibrary.SWAGGER1.equals(getAnnotationLibrary())) {
throw new IllegalArgumentException(AnnotationLibrary.SWAGGER1.getPropertyName() + " is not supported with Spring Boot > 3.x"); throw new IllegalArgumentException(AnnotationLibrary.SWAGGER1.getPropertyName() + " is not supported with Spring Boot > 3.x");
} }
useJakartaEe=true;
additionalProperties.put(USE_JAKARTA_EE, useJakartaEe);
applyJakartaPackage(); applyJakartaPackage();
} }
writePropertyBack(USE_SPRING_BOOT3, isUseSpringBoot3()); writePropertyBack(USE_SPRING_BOOT3, isUseSpringBoot3());