How to generate pojo from json schema by maven

Generate json schema from json

you can generate json schema online through the following website.

http://jsonschema.net/

Generate pojo by maven

Add the following maven configuration to your pom.xml, and execute maven command. you will find pojo generated by maven in your project.

<properties>
    <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
    <maven.compiler.encoding>UTF-8maven.compiler.encoding>
properties>

<dependencies>
        <dependency>
            <groupId>commons-langgroupId>
            <artifactId>commons-langartifactId>
            <version>2.4version>
        dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.coregroupId>
            <artifactId>jackson-databindartifactId>
            <version>2.0.0version>
        dependency>
dependencies>

<build>
    <testSourceDirectory>src/test/javatestSourceDirectory>
    <defaultGoal>installdefaultGoal>
    <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <configuration>
                    <source>1.6source>
                    <target>1.6target>
                    <encoding>UTF-8encoding>
                configuration>
            plugin>
            <plugin>
                <groupId>org.jsonschema2pojogroupId>
                <artifactId>jsonschema2pojo-maven-pluginartifactId>
                <version>0.4.20version>
                <configuration>
                    <sourceDirectory>${basedir}/src/main/resources/schemasourceDirectory>
                    <targetPackage>com.example.typestargetPackage>
                configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>generategoal>
                        goals>
                    execution>
                executions>
            plugin>
        plugins>
build>

Note: you need put your json schema in path ${basedir}/src/main/resources/schema. 
you can visit website https://github.com/joelittlejohn/jsonschema2pojo for more information.

你可能感兴趣的:(JBoss,Fuse)