java - Hibernate3 Maven 插件错误 : Could not create or find "MyReverseStrategy.java" with one argument delegate constructor?

标签 java maven reverse-engineering hibernate-tools hibernate3-maven-plugin

我正在使用 Hibernate3 Maven Plugin 进行逆向工程,这是我的 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>

效果很好。

关于java - Hibernate3 Maven 插件错误 : Could not create or find "MyReverseStrategy.java" with one argument delegate constructor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22908398/

相关文章:

node.js - 构建 Apache Zeppelin 时构建失败

mysql - 将 ERD 正向工程到 Mysql

java - 404 请求的资源在非常简单的 servlet 上不可用

java - 是什么导致了 java.lang.ArrayIndexOutOfBoundsException 以及如何防止它?

spring - mvn clean install 会导致 Surefire 错误

java utillogging在属性文件中配置过滤器

java - ASN.1 解码错误

java - 简化的 Java 8 Stream 将实体映射到模型

IBM PS/2 型号 30 286 的编译器

python - 在 C python 中,访问字节码评估堆栈