JAXB maven plugin not generating classes

拈花ヽ惹草 提交于 2019-12-04 02:53:04

The first thing is that you should never, ever, generate code inside src/main/java. Generated code should not be version-controlled and can be deleted at any-time since it will be regenerated anyway.

Generated code should always be located under target, the build directory of Maven. The jaxb2-maven-plugin will generate classes by default under target/generated-sources/jaxb and there's really no reason to change that. If you're using Eclipse, you just need to add this folder to the buildpath by right-clicking it and selecting "Build Path > Use a Source Folder".

When running Maven, you will run it with mvn clean install: it will clean the target folder and regenerate everything from scratch: this leads to a safe and maintainable build. You'll find that this will solve your problem: since the generated classes are deleted before the build, they will be correctly re-generated during the next build.

Of course, if this generation process is long and you don't want to do it each time, you can run Maven with just mvn install and configure the plugin not to remove the previously generated classes by setting clearOutputDir to false. But do note that, while the build will be slightly faster, you may not detect subsequent errors in your XSD if they are updated.

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