Unable to generate Java classes from JSON Schema using JsonSchema2Pojo-maven-plugin

心不动则不痛 提交于 2020-01-14 03:06:46

问题


I have used the following URL to understand the usage of JsonSchema2Pojo plugin https://github.com/joelittlejohn/jsonschema2pojo/wiki/Getting-Started#the-maven-plugin

However, I am unable to generate any class for the address schema. I have followed the same step as mentioned in the source but still no java class has been generated for address schema. I don't understand what can I do now. Please help me with a proper explanation.


回答1:


Double check your pom.xml and your project setup. The instructions on the wiki worked for me, here are the steps I took (OSX)

  1. Generate the initial project and pom.xml

    mvn archetype:generate -DgroupId=com.stackoverflow.example -DartifactId=example -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
    
  2. Download the address schema to ./src/main/resources/schema/address.json

  3. Update the pom.xml as described on the JsonSchema2Pojo documentation

  4. Generate the files

    $ find . -type f
    ./pom.xml
    ./src/main/java/com/stackoverflow/example/App.java
    ./src/main/resources/schema/address.json
    ./src/test/java/com/stackoverflow/example/AppTest.java
    $ mvn package
    
  5. Generated files will be under ./target/java-gen directory

    $ find . -name Address.java
    ./target/java-gen/com/example/types/Address.java
    


来源:https://stackoverflow.com/questions/33146633/unable-to-generate-java-classes-from-json-schema-using-jsonschema2pojo-maven-plu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!