当我调试我的代码时,它会转到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)
答案 0 :(得分:0)
只需添加sheltem的评论作为答案:
链接告诉你问题是什么实际上在消息中:slf4j.org/codes.html#version_mismatch首先处理slf4j版本不匹配,然后担心log4j配置(这不是原因错误,因为它只是一个警告)。
之后,如果您仍想使用log4j作为slf4j绑定(而不是logback),请在src/test/resources
中添加log4j.properties(这是假设您正在使用maven或gradle),或{module}-log4j.properties
,并将此属性文件定义为surefire插件中的日志配置,例如pom.xml中的系统属性(假设为maven):
<log4j.configuration>${project.artifactId}-log4j.properties</log4j.configuration>
答案 1 :(得分:-1)
将log4j.properties放入src/main/resources
。