Hibernate教程。 Maven编译的MojoFailureException

时间:2013-06-19 16:17:54

标签: java hibernate maven compiler-errors

这次我开始学习 Hiberante mvn compile有编译错误:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building First Hibernate Tutorial 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ hibernate-tutorial --
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ hibernate-tutorial ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Dokumente und Einstellungen\Ettling\tutorial-hibernate\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] \Dokumente und Einstellungen\Ettling\tutorial-hibernate\src\main\java\org\hibernate\tutorial\util\HibernateUtil.java:[17,89] error: cannot find symbol
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.344s
[INFO] Finished at: Wed Jun 19 17:53:44 CEST 2013
[INFO] Final Memory: 8M/23M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
3.2:compile (default-compile) on project hibernate-tutorial: Compilation failure
[ERROR] \Dokumente und Einstellungen\Ettling\tutorial-hibernate\src\main\java\org\hibernate\tutorial\util\HibernateUtil.java:[17,89] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/MAVE/MojoFailureException

我也是 Maven 的新人,所以对我来说有点困难。

HibernateUtil类代码

package org.hibernate.tutorial.util;

import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

public class HibernateUtil {

    public static final SessionFactory SESSION_FACTORY = buildSessionFactory();

    private static SessionFactory buildSessionFactory() throws HibernateException {
        Configuration configuration = new Configuration();
        configuration.configure();
        ServiceRegistry serviceRegistry =
                new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
        return configuration.buildSessionFactory(serviceRegistry);
    }
}

如果我目前了解本课程中的问题,但我真的无法理解缺少哪个符号。

感谢您的时间。

1 个答案:

答案 0 :(得分:2)

问题解决了。 这是一个maven bug。您也可以使用JDK 6来解决此问题。