I am working on a spring boot maven project in Eclipse IDE. And here is my pom.xml.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <description>Swagger Java</description>
...ommited for brevity




When I compile the project using mvn compile it executes swagger code gen plugin, it uses customer json schema to generate Model classes and then outputs all the generated classes to swagger folder under target folder.

I know that I can keep all the generated classes under target folder itself as maven executes swagger plugin before compiling the actual source code. So right now there is no issue with it.

But all the generated classes are Model classes which are used for processing request and response data.Currently there is no issue in doing so, but in future we might add additional functionality which might require updates to generated model classes and may be difficult to update them from target folder.

My main question is should I move all the generated pojo classes to something like src/main/org/**/* folder or keep the model classes inside target folder itself? What is the better approach including other alternatives?

  • Sharing your research helps everyone. Tell us what you've tried and why it didn't meet your needs. This demonstrates that you've taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask
    – gnat
    Feb 25, 2021 at 4:35
  • 1
    I have updated my question Feb 25, 2021 at 4:49

1 Answer 1


First in the moment someone starts updating the pojo files manually you will lose the capability to autogenerate them from the schema.

This is not something you want. If additional logic is needed there are plenty of other ways to achieve it like - decorators, helper classes and so on.

So, the correct place for your autogenerated classes is in your target folder. I would recommend you though to create a dedicated module that will just hold the generated sources and any customizations on top that you potentially may want to introduce.

When I say customizations I don't mean modifications to generated code I mean custom mappings, or custom types, converters and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.