Java Architecture for XML Binding (JAXB) provides a fast and convenient
way to bind XML schemas and Java representations, making it easy for
Java developers to incorporate XML data and processing functions in Java
applications. As part of this process, JAXB provides methods for unmarshalling
(reading) XML instance documents into Java content trees,
and then marshalling (writing) Java content trees back into XML instance
documents. JAXB also provides a way to generate XML schema from Java
objects and vice-versa.
Here we are going to talk about generating java objects from your XSD (XML Schema Definition).
Note : If you are using only Ant for your build, the flow is explained here.
Lets get started !
We need to build a pom file for Maven build. The structure and functionality is explained below :
Here we are going to talk about generating java objects from your XSD (XML Schema Definition).
Note : If you are using only Ant for your build, the flow is explained here.
Lets get started !
We need to build a pom file for Maven build. The structure and functionality is explained below :
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gv.test</groupId>
<artifactId>Test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>Test jar</name>
<!-- Directory that holds the schema files temporarily -->
<properties>
<test.schema.sourceDir>${project.build.directory}/tmpSchema</test.schema.sourceDir>
</properties>
<!-- Add JAXB jar dependencies -->
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>1.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>1.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.msv.datatype.xsd</groupId>
<artifactId>xsdlib</artifactId>
<version>20060615</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${basedir}/src</sourceDirectory>
<!-- Resources to be copied in your jar -->
<resources>
<resource>
<directory>${project.build.sourceDirectory}</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
<plugins>
<!-- Ant run plugin to pre-process schema and binding files -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>Test</id>
<goals>
<goal>run</goal>
</goals>
<phase>process-resources</phase>
<inherited>false</inherited>
<configuration>
<target>
<mkdir dir="${test.schema.sourceDir}" />
<copy todir="${test.schema.sourceDir}" overwrite="true">
<fileset dir="${basedir}/Schema"
includes="gvSchema.xsd,gvBindings.xjb" />
</copy>
<replaceregexp match="&quot;xsd:date&quot;"
flags="gs" replace="&quot;xsd:string&quot;" byline="false">
<fileset dir="${test.schema.sourceDir}" includes="*.xsd" />
</replaceregexp>
<replaceregexp match="(&lt;jxb:globalBindings)"
flags="gs" replace="&lt;!-- \0" byline="false">
<fileset dir="${test.schema.sourceDir}" includes="gvBindings.xjb" />
</replaceregexp>
<replaceregexp match="(&lt;\/jxb:globalBindings&gt;)"
flags="gs" replace="\0 --&gt;" byline="false">
<fileset dir="${test.schema.sourceDir}" includes="gvBindings.xjb" />
</replaceregexp>
</target>
</configuration>
</execution>
</executions>
</plugin>
<!-- XJC binding compiler plugin -->
<plugin>
<groupId>org.jvnet.jaxb1.maven2</groupId>
<artifactId>maven-jaxb1-plugin</artifactId>
<version>1.0-rc11</version>
<executions>
<execution>
<id>Test</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${test.schema.sourceDir}</schemaDirectory>
<generateDirectory>${project.build.sourceDirectory}</generateDirectory>
<bindingDirectory>${test.schema.sourceDir}</bindingDirectory>
<generateMarshallingCode>true</generateMarshallingCode>
<generateUnmarshallingCode>true</generateUnmarshallingCode>
<removeOldOutput>true</removeOldOutput>
</configuration>
</plugin>
<!-- Resources plugin attached here to copy .properties files after xjc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>default-resources</id>
<phase>compile</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Java compiler plugin to compile files generated by xjc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- Calling install before post install clean -->
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Post install clean -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>post-install-clean</id>
<phase>install</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<filesets>
<fileset>
<directory>${project.build.sourceDirectory}</directory>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The Best Bet | Thauberbet | Online Bets | Freebets betway login betway login 메리트카지노 메리트카지노 248무소유 토토 주소유 토토토 토토토 토토 주소유 토토토
ReplyDelete
ReplyDeleteYes I love to want python full stack developer course in bangalore with placement