Iacus Iacus - 1 year ago 267
Java Question

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
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download