【问题标题】:hibernate3-maven-plugin 3.0 run fine in Eclipse with m2eclipse but failed with standalone mavenhibernate3-maven-plugin 3.0 在 Eclipse 中使用 m2eclipse 运行良好,但使用独立 maven 失败
【发布时间】:2012-05-02 21:46:27
【问题描述】:

我将 Eclipse Indigo 与 M2Eclipse 1.0.200.20111228-1245 一起使用,我想使用 hibernate3-maven-plugin 3.0 版从我的 Hibernate 配置文件和映射文件生成数据库模式。这是我的 pom.xml 中的插件 xml sn-p。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>3.0</version>
    <executions>
        <execution>
            <id>create-schema</id>
            <phase>process-test-resources</phase>
            <goals>
                <goal>hbm2ddl</goal>
            </goals>
            <configuration>
                <components>
                    <component>
                        <name>hbm2ddl</name>
                        <implementation>configuration</implementation>
                    </component>
                </components>
                <hibernatetool destdir="${project.basedir}">
                    <classpath>
                        <path
                            location="${project.basedir}/src/main/resources/mappings/" />
                    </classpath>
                    <configuration
                        configurationfile="${project.basedir}/src/test/resources/hibernate.cfg.xml" />
                    <hbm2ddl create="true" export="false"
                        drop="true" outputfilename="schema.sql"
                        format="true" console="false" />
                </hibernatetool>
            </configuration>
        </execution>
    </executions>
</plugin>

通过上述配置,我可以使用 m2eclipse(嵌入式 maven 3.0.2)在 Eclipse 中运行“Maven 构建”,并且目标“process-test-resources”就好了。但是当我尝试使用独立的 maven (3.0.4) 运行时,我遇到了这样的异常

[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:3.0:hbm2ddl (default-cli) on project amlbs: There was an error creating the AntRun task. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:3.0:hbm2ddl (default-cli) on project amlbs: There was an error creating the AntRun task.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    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)
Caused by: org.apache.maven.plugin.MojoExecutionException: There was an error creating the AntRun task.
    at org.codehaus.mojo.hibernate3.AbstractHibernateMojo.execute(AbstractHibernateMojo.java:84)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: java.lang.NullPointerException
    at org.codehaus.plexus.configuration.DefaultPlexusConfiguration.add(DefaultPlexusConfiguration.java:170)
    at org.codehaus.plexus.configuration.DefaultPlexusConfiguration.addChild(DefaultPlexusConfiguration.java:146)
    at org.codehaus.mojo.hibernate3.util.PlexusConfigurationUtils.setHibernateConfiguration(PlexusConfigurationUtils.java:289)
    at org.codehaus.mojo.hibernate3.util.PlexusConfigurationUtils.parseHibernateTool(PlexusConfigurationUtils.java:67)
    at org.codehaus.mojo.hibernate3.AbstractHibernateToolMojo.getConfiguration(AbstractHibernateToolMojo.java:60)
    at org.codehaus.mojo.hibernate3.AbstractHibernateMojo.execute(AbstractHibernateMojo.java:76)
    ... 21 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

任何帮助将不胜感激!

【问题讨论】:

  • 不是一个反问:components 仍然与插件 3.0 相关吗?

标签: hibernate maven-plugin


【解决方案1】:

如果有任何帮助,这里是hibernate3-maven-plugin 3.0 版的工作配置。它正在启动hbm2java(您的问题是针对hbm2ddl),但无论如何在我看来它很有用,尤其是在没有其他人回答的情况下(还)。

<configuration>
    <hibernatetool>
        <classpath>
            <path location="${project.build.testOutputDirectory}" />
        </classpath>
        <jdbcconfiguration
            propertyfile="${basedir}/jpa-reveng/hibernate.properties"
            revengfile="${basedir}/jpa-reveng/hibernate.reveng.xml"
            reversestrategy="com.package.MyReverseEngineeringStrategy" />
        <hbm2java jdk5="true" ejb3="true"
            destdir="${project.build.sourceDirectory}" />
    </hibernatetool>
</configuration>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    • 1970-01-01
    • 2011-06-18
    • 2012-08-28
    相关资源
    最近更新 更多