[英]hibernate3 maven plugin:make hbm2java generate hibernate annotations instead of ejb3 annotations
[英]Hibernate3 Maven Plugin ERROR: Could not create or find “MyReverseStrategy.java” with one argument delegate constructor?
我正在使用Hibernate3 Maven插件進行逆向工程,這是我pom.xml的一部分
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hbm2java</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>jdbcconfiguration</implementation>
<outputDirectory>target/generatedClasses</outputDirectory>
</component>
</components>
<componentProperties>
<jdk5>true</jdk5>
<ejb3>false</ejb3>
<revengfile>/src/main/resources/reverse/engineering/hibernate.reveng.xml</revengfile>
<reversestrategy>/src/main/resources/reverse/engineering/MyReverseEngineeringStrategy.java</reversestrategy>
<propertyfile>src/main/resources/hibernate.properties</propertyfile>
<configurationFile>target/generatedClasses/hibernate.cfg.xml</configurationFile>
</componentProperties>
</configuration>
</execution>
看起來與數據庫的連接是可以的,但是它會按照默認的reverseStrategy創建類,而不是我聲明為“ MyReverseEngineeringStrategy.java”的類。 我在堆棧跟蹤中收到此錯誤。
[ERROR] Could not create or find /src/main/resources/reverse/engineering/MyReverseEngineeringStrategy.java with one argu
ment delegate constructor
java.lang.ClassNotFoundException: /src/main/resources/reverse/engineering/MyReverseEngineeringStrategy.java
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
at org.codehaus.mojo.hibernate3.configuration.JDBCComponentConfiguration.loadReverseStrategy(JDBCComponentConfig
uration.java:100)
at org.codehaus.mojo.hibernate3.configuration.JDBCComponentConfiguration.doConfiguration(JDBCComponentConfigurat
ion.java:42)
at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentC
onfiguration.java:56)
at org.codehaus.mojo.hibernate3.HibernateExporterMojo.configureExporter(HibernateExporterMojo.java:200)
at org.codehaus.mojo.hibernate3.HibernateExporterMojo.doExecute(HibernateExporterMojo.java:273)
at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:365)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
使用eclipse上的hibernate工具插件,我可以使用反向策略生成類,但是我希望我的項目獨立於eclipse。 有什么建議么!
真是愚蠢,但錯誤消息並沒有幫助我。 所以問題出在
<reversestrategy>/src/main/resources/reverse/engineering/MyReverseEngineeringStrategy.java</reversestrategy>
當我更改為以下內容時,
<reversestrategy>reverse.engineering.MyReverseEngineeringStrategy</reversestrategy>
它工作得很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.