0

当我调试我的代码时,它会转到 hibernateUtil,在它显示以下错误后我会这样做

og4j:WARN No appenders could be found for logger (com.gidiserver.util.HibernateUtil).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/String;
    at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:246)
    at org.hibernate.type.BasicTypeRegistry.register(BasicTypeRegistry.java:147)
    at org.hibernate.type.BasicTypeRegistry.<init>(BasicTypeRegistry.java:50)
    at org.hibernate.type.TypeResolver.<init>(TypeResolver.java:59)
    at org.hibernate.cfg.Configuration.<init>(Configuration.java:250)
    at org.hibernate.cfg.Configuration.<init>(Configuration.java:302)
    at com.gidiserver.serviceimpl.GidiBrainServiceImpl.displaySubjectDetails(GidiBrainServiceImpl.java:554)
    at com.gidiserver.serviceimpl.GidiBrainServiceImpl.main(GidiBrainServiceImpl.java:2194)
4

2 回答 2

0

只需添加 sheltem 的评论作为答案:

告诉您问题所在的链接实际上在消息中是正确的:slf4j.org/codes.html#version_mismatch 先处理 slf4j 版本不匹配,然后担心 log4j 配置(这不是错误的原因,因为这只是一个警告)。

之后,如果您仍想使用 log4j 作为 slf4j 绑定(而不是logback),请添加一个 log4j.properties src/test/resources(这一切都假设您使用的是 maven 或 gradle),或者{module}-log4j.properties,并将此属性文件定义为您在 surefire 插件中的日志配置,例如 pom.xml 中的系统属性(假设 maven):

<log4j.configuration>${project.artifactId}-log4j.properties</log4j.configuration>
于 2014-02-07T18:58:03.973 回答
-1

log4j.properties放入 src/main/resources.

于 2014-02-06T12:25:48.503 回答