Search code examples
javaclassmethodsdata-modelingpojo

java: class Profile is public, should be declared in a file named Profile.java error for unstructured data model and pojo


I have the following data model: where jobs is an embedded document and the remaining

and i wrote the pojo for the above data model as below:


Solution

  • If all classes are in the same file you have to remove public from other classes.

    If your filename is Profile.java, then, you have to use:

    public class Profile{...}
    

    The other classes like public class Environment you should remove the public:

    class Environment{...}
    class Payload{...}
    class data{...}
    

    I recommend use those classes in separate files, with its respective name. If you do this, you have to use the public class now.