maven使用插件利用json生成javabean 发表于 2017-08-26 | 分类于 java 阅读次数: 使用如下样例代码,注意json文件位置 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162<plugin> <groupId>org.jsonschema2pojo</groupId> <artifactId>jsonschema2pojo-maven-plugin</artifactId> <version>0.4.30</version> <executions> <execution> <id>execution1</id> <phase>generate-sources</phase> <configuration> <sourcePaths> <sourcePath>${basedir}/schema/settings.json</sourcePath> <sourcePath>${basedir}/schema/stuStaticInfos.json</sourcePath> <sourcePath>${basedir}/schema/gradeInfo.json</sourcePath> </sourcePaths> <targetPackage>com.hqjl.classify.input.model</targetPackage> <sourceType>json</sourceType> <serializable>false</serializable> <classNameSuffix>Model</classNameSuffix> <generateBuilders>true</generateBuilders> </configuration> <goals> <goal>generate</goal> </goals> </execution> <execution> <id>execution2</id> <phase>generate-sources</phase> <configuration> <sourcePaths> <sourcePath>${basedir}/schema/results.json</sourcePath> </sourcePaths> <targetPackage>com.hqjl.classify.result.model</targetPackage> <sourceType>json</sourceType> <serializable>false</serializable> <classNameSuffix>Model</classNameSuffix> <generateBuilders>true</generateBuilders> </configuration> <goals> <goal>generate</goal> </goals> </execution> <execution> <id>execution3</id> <phase>generate-sources</phase> <configuration> <sourcePaths> <sourcePath>${basedir}/schema/actionId.json</sourcePath> </sourcePaths> <targetPackage>com.hqjl.classify.request</targetPackage> <sourceType>json</sourceType> <serializable>false</serializable> <classNameSuffix>Model</classNameSuffix> <generateBuilders>true</generateBuilders> </configuration> <goals> <goal>generate</goal> </goals> </execution> </executions></plugin>