[Java][Spring] Fix useBeanValidation=false still generating NotNull annotation
Description
Fixes #23751.
When useBeanValidation is set to false, the Java Spring and java-camel generators previously still generated:
import {{javaxPackage}}.validation.constraints.NotNull;inJavaSpring/model.mustache@NotNullannotation on getters of required fields inJavaSpring/pojo.mustacheandjava-camel-server/pojo.mustache(the fallback block was originally added in #13580 for issue #13365 / #13196)
Because setting useBeanValidation: false excludes jakarta.validation (and spring-boot-starter-validation) dependencies from the generated build configuration, the generated model classes failed compilation with package jakarta.validation.constraints does not exist.
This PR removes the {{^useBeanValidation}} blocks generating NotNull imports and annotations in JavaSpring/model.mustache, JavaSpring/pojo.mustache, and java-camel-server/pojo.mustache. When useBeanValidation is true, @NotNull is already generated via beanValidation.mustache.
Existing tests asserting the previous behavior have been updated, and new unit tests have been added in SpringCodegenTest to verify that when useBeanValidation: false, no @NotNull annotations or validation imports are generated for Spring and java-camel servers.
PR checklist
- Read the contribution guidelines.
- Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
- Run the following to build the project and update samples:
Passed tests inSpringCodegenTestand checkstyle validation. - If your PR is targeting a particular programming language, @mention the technical committee members:
@OpenAPITools/generator-core-team