Classes made by openapi-generator-maven-plugin do not compile
Fix it fast
Most common cause, 1 of 3openApiNullable is on but jackson-databind-nullable is not in the pom
Add the library, or turn the option off in configOptions if you do not need to tell an explicit null apart from a missing field.
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.13</version>
</dependency>
<!-- or, inside the plugin's <configOptions> -->
<openApiNullable>false</openApiNullable>Short answer
Code from openapi-generator-maven-plugin fails with cannot find symbol when the generator's defaults expect libraries your pom lacks. openApiNullable is on by default and needs jackson-databind-nullable; useBeanValidation is on and needs spring-boot-starter-validation; useSpringBoot3 decides javax versus jakarta imports. Add the dependency or switch the option off. Applies to plugin 7.27.0 and Spring Boot 3.5 or 4.2.
Which cause do you have?
Compile once and read the first missing package in the output. The package name points straight at the cause: org.openapitools.jackson.nullable, a validation package, or a javax import inside a jakarta project.
mvn -q compile 2>&1 | grep -m 5 -E "does not exist|cannot find symbol"Then find the line you see in this list and open its fix:
- 1openApiNullable is on but jackson-databind-nullable is not in the pom
The first error is package org.openapitools.jackson.nullable does not exist, followed by cannot find symbol JsonNullable - 2Bean Validation annotations are generated but no validation library is present
Errors name jakarta.validation or symbols such as Valid, NotNull, Size and Pattern - 3Generated imports use javax while the project is on jakarta, or the reverse
The missing package starts with javax. in a Spring Boot 3 or 4 project, or with jakarta. in an old Spring Boot 2 project
What does the error look like?
package org.openapitools.jackson.nullable does not existsymbol: class JsonNullablepackage jakarta.validation.constraints does not existpackage javax.validation does not exist
Cause 1 of 3
openApiNullable is on but jackson-databind-nullable is not in the pom
You seeThe first error is package org.openapitools.jackson.nullable does not exist, followed by cannot find symbol JsonNullable
Check
The Spring generator's openApiNullable option defaults to true, which enables the OpenAPI Jackson Nullable library in generated models, so they import its JsonNullable wrapper. That class lives in the separate jackson-databind-nullable artifact, which the project's own pom has to declare; the generator's Spring Boot 3 sample pom lists it explicitly.
mvn dependency:tree -Dincludes=org.openapitools:jackson-databind-nullableFix
Add the library, or turn the option off in configOptions if you do not need to tell an explicit null apart from a missing field.
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.13</version>
</dependency>
<!-- or, inside the plugin's <configOptions> -->
<openApiNullable>false</openApiNullable>Verify
mvn compile finishes, and the dependency tree now lists jackson-databind-nullable.
mvn -q compile && echo compiledConfirmed by openapi-generator.tech
Cause 2 of 3
Bean Validation annotations are generated but no validation library is present
You seeErrors name jakarta.validation or symbols such as Valid, NotNull, Size and Pattern
Check
useBeanValidation defaults to true, which puts @Valid, @NotNull and similar annotations on the generated API and models. Those jakarta.validation types come from a Bean Validation jar, which Spring Boot normally gets through spring-boot-starter-validation; the generator's sample pom adds that starter next to the web starter.
mvn dependency:tree -Dincludes=jakarta.validationFix
Add the Spring Boot validation starter, which also brings a validator implementation. If you want no validation in generated code, set useBeanValidation to false instead.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>Verify
The validation errors disappear from the build output.
mvn -q compile && echo compiledConfirmed by raw.githubusercontent.com
Cause 3 of 3
Generated imports use javax while the project is on jakarta, or the reverse
You seeThe missing package starts with javax. in a Spring Boot 3 or 4 project, or with jakarta. in an old Spring Boot 2 project
Check
Spring Boot 3 and later use the Jakarta EE namespace. The generator picks javax or jakarta imports from useSpringBoot3, useSpringBoot4 and useJakartaEe; a config that sets useSpringBoot3 to false, or an old pinned plugin version, keeps writing javax imports.
grep -nE "useSpringBoot3|useSpringBoot4|useJakartaEe|openapi-generator-maven-plugin" pom.xmlFix
Match the option to your Spring Boot line. Use useSpringBoot3 for Boot 3 and useSpringBoot4 for Boot 4; both switch on useJakartaEe. Update the plugin to the current release while you are there, then clean so stale sources are regenerated.
<configOptions>
<useSpringBoot3>true</useSpringBoot3>
<!-- Spring Boot 4: <useSpringBoot4>true</useSpringBoot4> -->
</configOptions>
mvn clean compileVerify
The generated sources under target/generated-sources import jakarta packages only.
grep -rl "import javax.validation" target/generated-sources | wc -lConfirmed by openapi-generator.tech
How do I stop it coming back?
- Write every configOption you rely on into the pom explicitly, so a plugin upgrade that changes a default cannot change your imports.
- Copy the dependency block from the generator's sample pom for your Spring Boot line when you add the plugin.
- Run mvn clean compile in CI, so a stale generated-sources folder never hides a missing dependency.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Dispatch Pro.