Reputation: 1
I am using jsonschema2pojo-maven-plugin (0.4.19) to generate Java classes from JSON files.
I have 2 JSON files which have same field "xyz" with different attributes. So once I generate the "xyz" class from the 2nd JSON file, it replaces the first "xyz" class.
Is there any way to create 2nd class in a separate package, or is there any other way to avoid this issue?
Upvotes: 0
Views: 2547
Reputation: 11
Move each JSON file to a different subfolder in the source package:
${basedir}/src/main/resources/schema/request/request.json
${basedir}/src/main/resources/schema/response/response.json
Then with this configuration:
<configuration>
<sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
<targetPackage>com.example.types</targetPackage>
</configuration>
2 target packages will be generated:
com.example.types.request.*
com.example.types.response.*
Upvotes: 1