I am using the hibernate-tools-maven-plugin in a spring boot application.
I have added the revengStrategy as part of the plugin configuration and specified the full path of a class that extends DefaultReverseEngineeringStrategy.
Now, when I run mvn hibernate-tools:hbm2java, I get the following error.
[ERROR] Failed to execute goal org.hibernate:hibernate-tools-maven-plugin:5.4.20.Final:hbm2java (Entity generation) on project hibernate-tools-demo: Execution Entity generation of goal org.hibernate:hibernate-tools-maven-plugin:5.4.20.Final:hbm2java failed: com.jonamlabs.hibernatetoolsdemo.CustomReverseEngineeringStrategy not instanced. -> [Help 1]
Here com.jonamlabs.hibernatetoolsdemo.CustomReverseEngineeringStrategy is the class that extends DefaultReverseEngineeringStrategy
To reproduce the issue, refer to this GitHub project.
MacOS, MySQL, Spring Boot
What you are trying is not possible. The reverse engineering strategy is not compiled at the moment you are trying to generate the sources because this phase is earlier in the Maven life cycle. The solution is to provide the reverse engineering strategy in a different artifact for which you include dependencies in the pom file that needs to do the generation.
I have attached two simple projects as an example:
the archive ‘reveng-util.zip’ contains a Maven project with the custom reverse engineering strategy: expand it and use ‘mvn install’ to install the artifact in your local repo.
the archive ‘reveng-demo.zip’ contains a Maven project using the project above: expand it and use ‘mvn generate-sources’ to see the reverse engineering in action.
I am going to close this issue but feel free to reopen it if you have other or additional concerns.