开发者社区> 问答> 正文

不配置log4j就报错什么原因?报错

适用jetty启动项目报错

SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Found binding in [jar:file:/Users/zhoukai/.m2/repository/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: Found binding in [jar:file:/Users/zhoukai/Documents/myWorkspace/Permission-Model/target/tmp/webinf/WEB-INF/lib/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

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.

[WARNING] Failed startup of context o.m.j.p.JettyWebAppContext{/Permission-Model,[file:/Users/zhoukai/Documents/myWorkspace/Permission-Model/target/tmp/webinf/, file:/Users/zhoukai/Documents/myWorkspace/Permission-Model/src/main/webapp/, jar:file:/Users/zhoukai/.m2/repository/joker/good/custom/ExceptionHandler-Model/0.0.2/ExceptionHandler-Model-0.0.2.war!/]},file:/Users/zhoukai/Documents/myWorkspace/Permission-Model/src/main/webapp/

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/maindatabank.xml]: Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.hibernate.cfg.Configuration]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/String;

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:610)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)

at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:479)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java)

at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)

at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:641)

at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:228)

at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1181)

at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:584)

at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:496)

at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:180)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)

at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:226)

at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:164)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)

at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:226)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)

at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:93)

at org.eclipse.jetty.server.Server.doStart(Server.java:243)

at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:67)

at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)

at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:447)

at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:387)

at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:586)

at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)

at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)

at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)

at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)

at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)

at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)

at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)

at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)

at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)

at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)

at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)

at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)

at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

at org.codehaus.classworlds.Launcher.main(Launcher.java:46)

Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.hibernate.cfg.Configuration]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/String;

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:105)

at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newConfiguration(LocalSessionFactoryBean.java:821)

at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:552)

at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)

... 54 more

Caused by: 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 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)

... 60 more

展开
收起
爱吃鱼的程序员 2020-06-14 22:11:58 611 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    这一句是关键:

    SLF4J:Therequestedversion1.5.8byyourslf4jbindingisnotcompatiblewith[1.6]

    你的slf4j版本可能有问题.

    给你看了一下,你的slf4j-log4j是1.5.8的,而你的slf4j-api可能是1.6的

    NoSuchMethod,就是你调用了某方法,但是jar没引入呗 SLF4J:ClasspathcontainsmultipleSLF4Jbindings.这第一句话不就说得很清楚吗?你的类路径包含了多个sfl4j的绑定,看你似乎用了maven但又在 /WEB-INF/lib/下重复放了slf4j-log4j12-1.5.8.jar,把 /WEB-INF/lib/下的slf4j-log4j12-1.5.8.jar删掉试下。

    找到问题了..就是jar包版本错了

    版本冲突!!!!骚年
    2020-06-14 22:12:15
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
PostgresChina2018_赖思超_PostgreSQL10_hash索引的WAL日志修改版final 立即下载
Kubernetes下日志实时采集、存储与计算实践 立即下载
日志数据采集与分析对接 立即下载