5

「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た。考え?

4

2 に答える 2

18

ここであなたが望むものを解決します

異なるバージョンの slf4j アーティファクトを混在させると、問題が発生する可能性があります。たとえば、slf4j-api-1.6.1.jar を使用している場合は、slf4j-simple-1.6.1.jar も使用する必要があります。slf4j-simple-1.5.5.jar を使用しても機能しません。

一般に、slf4j-api のバージョンが slf4j binding のバージョンと一致していることを確認する必要があります

初期化時に、バージョンの不一致の問題がある可能性があると SLF4J が疑う場合、SLF4J は不一致の疑いに関する警告を発します。バージョン不一致検出メカニズムの正確な詳細については、FAQ の関連エントリを参照してください。

于 2010-09-22T20:44:48.367 に答える
3

以下は、互換性のない slf4j バージョンを使用している場合に、SLF4J の起動警告に出くわした例です。

SLF4J: slf4j バインディングによって要求されたバージョン 1.5.10 は、[1.6] SLF4J と互換性がありません: 詳細については、http: //www.slf4j.org/codes.html#version_mismatchを参照してください。

于 2011-12-22T13:36:40.250 に答える