In my resources folder src/main/resources
, I have an xsd folder with subfolders named create and update.
So the folder structure looks like :
src/main/resources/xsd
src/main/resources/xsd/create/create.xsd
src/main/resources/xsd/update/update.xsd
What I am trying to figure out is how to generate the Java Objects in their own respective packages to organize the code using XJC and maven-jaxb2-plugin
I want to generate the CREATE Java objects in src/main/java/com/myapp/dto/create
And UPDATE Java objects in src/main/java/com/myapp/dto/update
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<!-- user-added-plugin-->
<plugin>
<!-- https://mvnrepository.com/artifact/org.jvnet.jaxb2.maven2/maven-jaxb2-plugin -->
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.15.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- CREATE Schema-->
<schemaDirectory>${project.basedir}/src/main/resources/xsd/create</schemaDirectory>
<schemaIncludes>
<include>*.xsd</include>
</schemaIncludes>
<generatePackage>com.myapp.dto.create</generatePackage>
<generateDirectory>${project.basedir}/src/main/java</generateDirectory>
<!-- UPDATE Schema -->
<schemaDirectory>${project.basedir}/src/main/resources/xsd/update</schemaDirectory>
<schemaIncludes>
<include>*.xsd</include>
</schemaIncludes>
<generatePackage>com.myapp.dto.update</generatePackage>
<generateDirectory>${project.basedir}/src/main/java</generateDirectory>
</configuration>
</plugin>
</plugins>
</build>
My current pom.xml <build>
code only generates the UPDATE Java objects in com.myapp.dto.update
but it never generates CREATE Java objects in com.myapp.dto.create
. It does not even create the path: com.myapp.dto.create
I am not sure how to generate the CREATE on the desired path. Eventually I will need to generate Java objects for DELETE schema. That's why I'm hoping to generate the Java objects accordingly on their respective package/folders.