如何配置hibernate-entitymanager:4.3.8.Final与SLF4J配合使用?

时间:2015-03-28 04:21:19

标签: spring hibernate slf4j

我最近将hibernate-entitymanager版本从4.0.1更改为4.3.8.Fianl,之后我将项目部署到WildFly时出现此错误:

12:17:15,340 ERROR [stderr] (MSC service thread 1-5) log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.
12:17:15,341 ERROR [stderr] (MSC service thread 1-5) log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by 
12:17:15,341 ERROR [stderr] (MSC service thread 1-5) log4j:ERROR [ModuleClassLoader for Module "deployment.taolijie.war:main" from Service Module Loader] whereas object of type 
12:17:15,342 ERROR [stderr] (MSC service thread 1-5) log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [ModuleClassLoader for Module "org.jboss.log4j.logmanager:main" from local module loader @12bc6874 (finder: local module finder @de0a01f (roots: /home/whf/app/wildfly-8.0.0.Final/modules,/home/whf/app/wildfly-8.0.0.Final/modules/system/layers/base))].
12:17:15,342 ERROR [stderr] (MSC service thread 1-5) log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator].
12:17:15,347 ERROR [stderr] (MSC service thread 1-5) log4j:WARN No appenders could be found for logger (org.jboss.logging).
12:17:15,348 ERROR [stderr] (MSC service thread 1-5) log4j:WARN Please initialize the log4j system properly.
12:17:15,348 ERROR [stderr] (MSC service thread 1-5) log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

如果我将hinbernate-entitymanager的版本更改回4.0.1,一切都很好。 我不知道这个..怎么解决?

这是我的pom.xml:

<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <!--<version>4.0.1.Final</version>-->
            <version>4.3.8.Final</version>
        </dependency>
<dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>

1 个答案:

答案 0 :(得分:0)

Wildfly 8.2如果我没有错,已经包含了这个版本的hibernate实体管理器,所以改变你的依赖范围,只要它应该工作正常,并改变hibernate核心依赖关系提供,如果你有它在你的pom,hibernate将包括你在运行时的libs。