Skip to content

ClassNotFoundException when attempting to use a custom annotator from a project dependency #256

@Cuneytt

Description

@Cuneytt

Trying to generate POJOs from JSON examples (not schemas) using the following maven configuration:

                <groupId>org.jsonschema2pojo</groupId>
                <artifactId>jsonschema2pojo-maven-plugin</artifactId>
                <version>0.4.5</version>
                <configuration>
                    <sourceDirectory>src/main/resources/json</sourceDirectory>
                    <outputDirectory>${project.build.sourceDirectory}</outputDirectory>
                    <targetPackage>com.test.applications.service.model</targetPackage>
                    <sourceType>JSON</sourceType>
                    <generateBuilders>true</generateBuilders>
                    <includeHashcodeAndEquals>false</includeHashcodeAndEquals>
                    <annotationStyle>NONE</annotationStyle>
               </configuration>

this generates POJOs as expected without any annotations but still generates the addtionalProperties:

private Map<String, Object> additionalProperties = new HashMap<String, Object>();

I know disabling this is possible through schema declaration through "additionalProperties": false
but in my case I generate from json examples.

I tried to use a custom Annotator that will override the AbstractAnnotator and run it through maven:

public class CustomNoopAnnotator extends AbstractAnnotator{
    @Override
    public boolean isAdditionalPropertiesSupported() {
        return false;
    }
}

and additional config in maven:

<customAnnotator>com.test.application.generator.CustomNoopAnnotator</customAnnotator>

this class is another module and the module I am trying to generate POJOs from has a dependency to this module.

I get java.lang.ClassNotFound exception with this setup.

I'd appreciate any feedback as to how to disable additionalProperties HashMap from being generated using JSON source type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions