java - 开始 Hibernate 3.5 - Ant 任务的问题

标签 java hibernate ant slf4j

我正在努力学习“Beginning Hibernate 3.5”,但遇到了最初的障碍。

当我运行 ant exportDDL 时,出现以下错误:

exportDDL:
   [htools] Executing Hibernate Tool with a Hibernate Annotation/EJB3 Configuration
   [htools] 1. task: hbm2ddl (Generates database schema)
   [htools] SLF4J: The requested version 1.6 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8]
   [htools] SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
   [htools] An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
   [htools] To get the full stack trace run ant with -verbose
   [htools] Problems in creating a AnnotationConfiguration. Have you remembered to add it to the classpath ?
   [htools] java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;

BUILD FAILED
C:\hibernate\project\build.xml:30: Problems in creating a AnnotationConfiguration. Have you
remembered to add it to the classpath ?

使用以下 Ant 任务:

<target name="exportDDL" depends="compile">
    <mkdir dir="${sql}"/>
    <htools destdir="${sql}">
        <classpath refid="classpath.tools"/>
        <annotationconfiguration
                configurationfile="${src}/hibernate.cfg.xml"/>
        <hbm2ddl drop="true" outputfilename="sample.sql"/>
    </htools>
</target>
<target name="compile">
    <javac srcdir="${src}" destdir="${bin}" classpathref="classpath.base"/>
</target>

这是怎么回事? ant compile 工作正常,但 exportDDL 任务没有。 sl4j jar 在类路径中,我下载了 slf4j-simple-1.6.1.jar。想法?

最佳答案

这里解决你想要的

Mixing mixing different versions of slf4j artifacts can cause problems. For example, if you are using slf4j-api-1.6.1.jar, then you should also use slf4j-simple-1.6.1.jar, using slf4j-simple-1.5.5.jar will not work.

In general, you should make sure that the slf4j-api version matches that of the slf4j binding.

At initialization time, if SLF4J suspects that there may be a version mismatch problem, it will emit a warning about the suspected mismatch. For the exact details of the version mismatch detection mechanism, please refer to the relevant entry in the FAQ.

关于java - 开始 Hibernate 3.5 - Ant 任务的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3773379/

相关文章:

java - 如何在 Android 中录制视频,仅允许横向模式并设置最长录制时间

java - 混合读取的gson

java - 处理大量元素时 hibernate 内存不足异常

java - ADF 概念 - 两个站点之间的通信

java - 使用多线程更新数据库时如何避免 "lock timeout"?

java - hql 的字符串分割函数

tomcat - 更改war的上下文路径,无法使用ant添加JSP文件夹

android - 如何在 Windows XP 上的单个批处理文件中执行 "android update project"命令列表?

Eclipse 3.3.2/MyEclipse 无法将 xml 识别为 ant 文件

java - Selenium - 通过 ul li 值文本从列表中选择项目