2 weixin 37057242 weixin_37057242 于 2017.09.13 10:55 提问

spring整合shiro启动项目报错,创建shiroFilter失败

22:15:56,642 WARN XmlWebApplicationContext:546 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in URL [file:/D:/LnSoftware/Tomcat/7.0.52/apache-tomcat-7.0.52/webapps/logistic_web/WEB-INF/classes/applicationContext-shiro.xml]: Instantiation of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type gerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory; used in the signature
22:15:56,653 ERROR ContextLoader:353 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in URL [file:/D:/LnSoftware/Tomcat/7.0.52/apache-tomcat-7.0.52/webapps/logistic_web/WEB-INF/classes/applicationContext-shiro.xml]: Instantiation of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type gerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory; used in the signature
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1105)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:240)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:687)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

2个回答

qq_34379959
qq_34379959   2017.09.13 10:57

Error creating bean with name 'shiroFilter' defined in URL [file:/D:/LnSoftware/Tomcat/7.0.52/apache-tomcat-7.0.52/webapps/logistic_web/WEB-INF/classes/applicationContext-shiro.xml
这句话错了啊。说你这个xml里面没有配置对

weixin_37057242
weixin_37057242 谢谢啊,找到原因了, web.xml和applicationContext.xml的配置没问题, 是因为slf4j的jar包冲突引起的
2 个月之前 回复
weixin_37057242
weixin_37057242   2017.09.13 10:59

问题已解决:maven项目中slf4j的jar包冲突导致,
点开pom.xml的 Dependency Hierarchy中,找到版本不一样的jar包,选中jar包后面有omitted for conflict with....的jar包,右键Exclude maven artifact即可

Csdn user default icon
上传中...
上传图片
插入图片