spring- No bean named 'shiroFilter' is defined

问题描述

No bean named 'shiroFilter' is defined
要把shiro整合进入spring出现了这个错误,'shiroFilter' 这个bean已经定义过了的着急在线等。。

严重: Exception starting filter shiroFilter
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'shiroFilter' is defined

web.xml

 <?xml version=""1.0"" encoding=""UTF-8""?><web-app xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://java.sun.com/xml/ns/javaee"" xmlns:web=""http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"" xsi:schemaLocation=""http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"" version=""2.5""><context-param>    <param-name>contextClass</param-name>    <param-value>    org.springframework.web.context.support.AnnotationConfigWebApplicationContext    </param-value></context-param>  <context-param>    <param-name>contextConfigLocation</param-name>    <param-value>classpath:applicationContext.xmlspring-shiro.xml</param-value>  </context-param>    <!-- apache shiro权限 -->    <filter>        <filter-name>shiroFilter</filter-name>        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>        <init-param>            <param-name>targetFilterLifecycle</param-name>            <param-value>true</param-value>        </init-param>    </filter>    <filter-mapping>        <filter-name>shiroFilter</filter-name>        <url-pattern>*.do</url-pattern>    </filter-mapping>    <filter-mapping>        <filter-name>shiroFilter</filter-name>        <url-pattern>*.jsp</url-pattern>    </filter-mapping>   <filter>        <filter-name>encodingFilter</filter-name>        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>        <init-param>            <param-name>encoding</param-name>            <param-value>utf-8</param-value>        </init-param>    </filter>    <filter-mapping>        <filter-name>encodingFilter</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping>        <listener>        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>    </listener>  <listener>    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  </listener>  <listener>        <listener-class>                    cn.edu.bzu.group4.stockplus.common.base.controller.ApplicationConfigurationFilter        </listener-class>  </listener>  <servlet>    <servlet-name>springservlet</servlet-name>    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>    <init-param>      <param-name>contextConfigLocation</param-name>      <param-value>classpath:applicationContext-servlet.xml</param-value>    </init-param>  </servlet>  <servlet-mapping>    <servlet-name>springservlet</servlet-name>    <url-pattern>/</url-pattern>  </servlet-mapping>      <error-page>        <error-code>404</error-code>        <location>/404</location>    </error-page></web-app>

spring-shiro.xml

 <?xml version=""1.0"" encoding=""UTF-8""?><beans xmlns=""http://www.springframework.org/schema/beans""       xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""       xmlns:aop=""http://www.springframework.org/schema/aop""       xmlns:tx=""http://www.springframework.org/schema/tx""       xmlns:util=""http://www.springframework.org/schema/util""       xmlns:context=""http://www.springframework.org/schema/context""       xsi:schemaLocation=""       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"">    <description>Shiro</description>    <bean id=""shiroFilter"" class=""org.apache.shiro.spring.web.ShiroFilterFactoryBean"">        <property name=""securityManager"" ref=""securityManager"" />        <property name=""loginUrl"" value=""/login"" />        <property name=""successUrl"" value=""/login"" />        <property name=""unauthorizedUrl"" value=""/404"" />        <property name=""filterChainDefinitions"">            <value>                /login.jsp* = anon                /login.do* = anon                /index.jsp*= anon                /error/noperms.jsp*= anon                /*.jsp* = authc                /*.do* = authc            </value>        </property>    </bean>    <bean id=""securityManager"" class=""org.apache.shiro.web.mgt.DefaultWebSecurityManager"">        <property name=""realm"" ref=""SampleRealm"" />    </bean>    <bean id=""lifecycleBeanPostProcessor"" class=""org.apache.shiro.spring.LifecycleBeanPostProcessor"" />    <bean id=""SampleRealm"" class=""com.shiro.service.MonitorRealm""></bean>    <bean        class=""org.springframework.beans.factory.config.MethodInvokingFactoryBean"">        <property name=""staticMethod""            value=""org.apache.shiro.SecurityUtils.setSecurityManager"" />        <property name=""arguments"" ref=""securityManager"" />    </bean>    <bean        class=""org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator""        depends-on=""lifecycleBeanPostProcessor"" />    <bean        class=""org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"">        <property name=""securityManager"" ref=""securityManager"" />    </bean></beans>

applicationContext.xml

 <?xml version=""1.0"" encoding=""UTF-8""?><beans xmlns=""http://www.springframework.org/schema/beans""    xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""    xmlns:context=""http://www.springframework.org/schema/context""     xmlns:tx=""http://www.springframework.org/schema/tx""    xmlns:aop=""http://www.springframework.org/schema/aop""    xmlns:mvc=""http://www.springframework.org/schema/mvc""    xsi:schemaLocation=""http://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-3.2.xsdhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd>    <bean class=""org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator""/>        <bean id=""dataSource"" class=""com.mchange.v2.c3p0.ComboPooledDataSource"">            <property name=""user"" value=""root""/>            <property name=""password"" value=""root""/>            <property name=""driverClass"" value=""com.mysql.jdbc.Driver""/>            <property name=""jdbcUrl"" value=""jdbc:mysql://10.2.7.121:3306/stockplus?characterEncoding=utf-8""/>            <property name=""maxPoolSize"" value=""30""/>            <property name=""minPoolSize"" value=""10""/>       </bean> <bean id=""sessionFactory""        class=""org.springframework.orm.hibernate4.LocalSessionFactoryBean"">        <property name=""dataSource"">            <ref bean=""dataSource"" />        </property>        <property name=""packagesToScan"">            <list>                <value>cn.edu.bzu.group4.stockplus.*</value>            </list>        </property>                <property name=""hibernateProperties"">            <props>                <prop key=""hibernate.dialect"">org.hibernate.dialect.MySQL5Dialect</prop>                <prop key=""hibernate.format_sql"">true</prop>                <prop key=""hibernate.show_sql"">true</prop>            </props>       </property>         <property name=""eventListeners"">            <map>                <entry key=""merge"">                    <bean class=""org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener""/>                </entry>            </map>        </property>    </bean>    <bean id=""transactionManager""        class=""org.springframework.orm.hibernate4.HibernateTransactionManager"">        <property name=""sessionFactory"" ref=""sessionFactory"" />    </bean>    <tx:annotation-driven transaction-manager=""transactionManager"" />    <!-- 拦截器方式配置事物 -->    <tx:advice id=""transactionAdvice"" transaction-manager=""transactionManager"">        <tx:attributes>            <tx:method name=""add*"" propagation=""REQUIRED"" />            <tx:method name=""save*"" propagation=""REQUIRED"" />            <tx:method name=""insert*"" propagation=""REQUIRED"" />            <tx:method name=""edit*"" propagation=""REQUIRED"" />            <tx:method name=""update*"" propagation=""REQUIRED"" />            <tx:method name=""modify*"" propagation=""REQUIRED"" />            <tx:method name=""repair"" propagation=""REQUIRED"" />            <tx:method name=""append*"" propagation=""REQUIRED"" />            <tx:method name=""delete*"" propagation=""REQUIRED"" />            <tx:method name=""remove*"" propagation=""REQUIRED"" />             <tx:method name=""get*"" propagation=""SUPPORTS"" />            <tx:method name=""load*"" propagation=""SUPPORTS"" />            <tx:method name=""datagrid*"" propagation=""SUPPORTS"" />            <tx:method name=""*"" propagation=""SUPPORTS"" />        </tx:attributes>    </tx:advice>    <aop:config>        <aop:pointcut id=""transactionPointcut""            expression=""execution(* cn.edu.bzu.group4stockplus.dao..*Dao.*(..))"" />        <aop:advisor pointcut-ref=""transactionPointcut""            advice-ref=""transactionAdvice"" />    </aop:config> <context:annotation-config/>    <context:component-scan base-package=""cn.edu.bzu.group4.stockplus.*""/></beans>

解决方案

解决未果,放弃,之后自己研究吧

解决方案二:
异常的意思是说shiroFilter没有定义,可能的一个原因是配置文件没有被编译,看看Tomcat下相应的位置是否有配置文件,如果木有,重新编译整个项目,重新部署到Tomcat。

......
答案就在这里:SuchBeanDefinitionException: No bean named 'shiroFilter' is defined

解决方案三:
没有引入指定包,还是filter的路径错了?按住ctrl,点击filter的路径如果变成链接样式,那么就说明路径有效。

时间: 2024-10-17 10:20:51

spring- No bean named &amp;#39;shiroFilter&amp;#39; is defined的相关文章

spring mvc-No bean named &amp;amp;#39;sessionFactory&amp;amp;#39; is defined错误

问题描述 No bean named 'sessionFactory' is defined错误 运行时 报No bean named 'sessionFactory' is defined错误 我用的是Eclipse 然后是Spring MVC + Hibernate + Maven编写的0.0 解决方案 java 异常问题 No bean named 'sessionFactory' is defined:http://blog.csdn.net/mypurse/article/detail

No bean named &amp;amp;#x27;/chance&amp;amp;#x27; is defined

问题描述 Nobeannamed'/chance'isdefined这个是那的错我注册插件也写了 解决方案 解决方案二:你的问题,谁能看懂?解决方案三:................解决方案四:/chance是表单bean中某个属性??拼写错了吧或者在表单bean中没有new解决方案五:你把问题再写详细一点!

sessionfactory-No bean named &amp;amp;#39;sessionFactory&amp;amp;#39; is defined

问题描述 No bean named 'sessionFactory' is defined 在加入spring security之后出现了下面的问题 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCrea

spring-h、s整合问题:No bean named &amp;amp;#39;sessionFactory&amp;amp;#39; is defined

问题描述 h.s整合问题:No bean named 'sessionFactory' is defined 我用的是hibernate和spring整合,在beans.xml写了sessionFactory.在类里面调用@Resource时就报错了 @Resource(name="sessionFactory") public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = s

No bean named &amp;amp;#39;sysConfigDAO&amp;amp;#39; is defined

问题描述 No bean named 'sysConfigDAO' is defined 1SysConfigService.java ...... package com.lfyc.foundation.service.impl; @Transactional @Service ("SysConfigService") public class SysConfigService implements ISysConfigService { @Resource(name="s

sessionfactory-服务器启动时 No bean named &amp;amp;#39;sessionFactory&amp;amp;#39; is defined

问题描述 服务器启动时 No bean named 'sessionFactory' is defined ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext()); 每一次调用这个就会使hibernate建立一个连接池, 在applicationContext-hibernate.xml中有数据库连接信息,数据库表映射信息(sessionfacto

javaee-No bean named &amp;amp;#39;SQService&amp;amp;#39; is defined

问题描述 No bean named 'SQService' is defined 这个问题如何解决No bean named 'SQService' is defined??? 解决方案 先看一下有没有配置SQService这个bean,如果有的话,再看看是不是这个配置文件没有加载进来. 解决方案二: 缺少了需要引入的头文件?

No bean named &amp;#39;transactionManager&amp;#39; is defined

  2016-10-20 23:27:17.771 INFO 7096 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework

Spring Task Scheduler - No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined

1. Overview In this article, we are discussing the Springorg.springframework.beans.factory.NoSuchBeanDefinitionException – this is a common exception thrown by the BeanFactory when trying to resolve a bean that simply isn't defined in the Spring Cont