Search code examples
javamavencompiler-errorsswagger-codegen

Failed to execute goal on project swagger-java-client: Compilation failure


Context: I'm trying to build a swagger-codegen-cli generated package to generate a jar as a dependency for a maven spring boot java project

Getting this error message when running mvn clean install:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] <path-to-project>/Projects/dev/Sellers_JavaCL/src/main/java/io/swagger/client/model/BatchRequest.java:[33,21] package javax.annotationmvn does not exist
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.041 s
[INFO] Finished at: 2024-02-18T18:07:32-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project swagger-java-client: Compilation failure
[ERROR] <path-to-project>/Projects/dev/Sellers_JavaCL/src/main/java/io/swagger/client/model/BatchRequest.java:[33,21] package javax.annotationmvn does not exist

I looked into the BatchRequest.java class and found this where annotationmvn is red in intellij because it can't be found:

@ApiModel(description = "Common properties of batch requests against individual APIs.")
@javax.annotationmvn.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2024-02-17T14:18:13.581-08:00")

This swagger java client package seems to be compiling in Java 1.7 my spring boot project is building in Java 17. I tried to download the old 1.7 jdk to build and compile this project but it just throws the same error.

Things I tried

  • Deleted my .m2 folder and rerun mvn clean install
  • Tried to change the JDK to 17, 11, 1.8, 1.7
  • Tried to resolve dependencies using mvn dependency:tree

Solution

  • Not found becouse doesn't exist @javax.annotationmvn.Generated

    @javax.annotation.Generated is correct :)