Search code examples
javamavenjsonschema2pojo

How do I avoid jsonschema2pojo generating duplicate classes that I already have?


I have a jsonschema file defining a class that I need as a child class of an already existing POJO (not defined by a schema)

As I found on the jsonschema2pojo documentation, the way to do it is:

{
...
"type": "object",
"extends": {
  "type": "object",
  "javaType": "com.example.Document"
},
"properties": { ... }

However, when I run maven clean install, the compilation fails because it tries to generate its own Document class (with the @Json... annotations and so on) and Maven throws this error

error: duplicate class: com.example.Document

According to the docs, the plugin shouldn't try to generate a class that already exists. How can I avoid this?


Solution

  • Solved it by adding the module as a dependency of jsonschema2pojo in the <plugin> section of the pom file.