java 开始 Hibernate 3.5 - 蚂蚁任务的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3773379/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Beginning Hibernate 3.5 - Problems with ant task
提问by Stefan Kendall
I'm trying to work through "Beginning Hibernate 3.5", and I've hit an initial snag.
我正在尝试完成“Beginning Hibernate 3.5”,但我遇到了最初的障碍。
When I run ant exportDDL
, I get the following error:
当我运行时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 ?
with the following ant task:
使用以下蚂蚁任务:
<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>
What's going on here? ant compile
works fine, but the exportDDL
task does not. The sl4j jar is on the classpath, and I downloaded slf4j-simple-1.6.1.jar
. Thoughts?
这里发生了什么?ant compile
工作正常,但exportDDL
任务没有。sl4j jar 在类路径上,我下载了slf4j-simple-1.6.1.jar
. 想法?
回答by Arthur Ronald
Here solves what you want
在这里解决你想要的
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.
混合不同版本的 slf4j 工件可能会导致问题。比如你使用的是slf4j-api-1.6.1.jar,那么你也应该使用slf4j-simple-1.6.1.jar,使用slf4j-simple-1.5.5.jar是不行的。
通常,您应该确保 slf4j-api 版本与 slf4j binding 的版本匹配。
在初始化的时候,如果 SLF4J 怀疑可能存在版本不匹配问题,它会发出关于怀疑不匹配的警告。有关版本不匹配检测机制的详细信息,请参阅 FAQ 中的相关条目。
回答by Ed S.
Here's an example I came across of the SLF4J start up warning when you've got incompatible slf4j versions:
这是当您有不兼容的 slf4j 版本时我遇到的 SLF4J 启动警告的示例:
SLF4J: The requested version 1.5.10 by your slf4j binding is not compatible with [1.6] SLF4J: See http://www.slf4j.org/codes.html#version_mismatchfor further details.
SLF4J:您的 slf4j 绑定请求的版本 1.5.10 与 [1.6] SLF4J 不兼容:有关更多详细信息,请参阅http://www.slf4j.org/codes.html#version_mismatch。