eclipse行,tomcat出现No bean named 'shiroFilter' is defined,为啥?

cow8063 2018-07-05 03:41:07
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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="jeefw" metadata-complete="true" version="3.0">
<display-name>ace</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:applicationContext*.xml,
classpath*:applicationContext-shiro.xml
</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>ace.webapp.root</param-value>
</context-param>
<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>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!-- 定时任务监听器 -->
<!-- <listener> <listener-class>core.util.timer.TimerDateTaskListener</listener-class>
</listener> -->

<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- shiroFilter过滤器 -->
<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>/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>chineseFilter</filter-name>
<filter-class>core.web.ChineseFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>chineseFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>characterEncoding</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>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>DruidWebStatFilter</filter-name>
<filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
<init-param>
<param-name>exclusions</param-name>
<param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
</param-value>
</init-param>
<init-param>
<param-name>profileEnable</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>sessionStatEnable</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>principalSessionName</param-name>
<param-value>SESSION_SYS_USER</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>DruidWebStatFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>DruidStatView</servlet-name>
<servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DruidStatView</servlet-name>
<url-pattern>/druid/*</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<!-- <async-supported>true</async-supported> 20171225添加-->



<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<!-- <servlet> <servlet-name>app_client_face</servlet-name> <servlet-class>com.jeefw.app.logic.ClientServerController
</servlet-class> </servlet> <servlet-mapping> <servlet-name>app_client_face</servlet-name>
<url-pattern>/client/face</url-pattern> </servlet-mapping> -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>401</error-code>
<location>/sys/sysuser/callUnauthorized</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/sys/sysuser/callError404</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/sys/sysuser/callError500</location>
</error-page>
</web-app>
...全文
540 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
  • 打赏
  • 举报
回复
cao,一段代码时什么意思,不解释就不要发
TangoAlone 2018-07-12
  • 打赏
  • 举报
回复
tomcat里清楚你部署的class,重新编译项目,重新部署到Tomcat
ssy03092919 2018-07-11
  • 打赏
  • 举报
回复
spring配置文件中应该没有配置'shiroFilter'这个bean
潘少丶 2018-07-10
  • 打赏
  • 举报
回复
shiro拦截器文件配置错误。有一个元素没有定义。
cow8063 2018-07-05
  • 打赏
  • 举报
回复
eclipse一切正常,目录结构

tomcat 目录结构,applicationContext-shiro.xml放在classes目录

出现
信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
05-Jul-2018 14:57:06.272 严重 [localhost-startStop-1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter [shiroFilter]
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'shiroFilter' is defined
这是为啥呀
cow8063 2018-07-05
  • 打赏
  • 举报
回复
applicationContext-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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-4.0.xsd
http://www.springframework.org/schema/context classpath:org/springframework/context/config/spring-context-4.0.xsd
http://www.springframework.org/schema/aop classpath:org/springframework/aop/config/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx classpath:org/springframework/transaction/config/spring-tx-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

<!-- 代码中得到当前用户:Subject currentUser = SecurityUtils.getSubject();
Subject代表了当前用户的安全操作
SecurityManager则管理所有用户的安全操作。
Realm充当了Shiro与应用安全数据间的“桥梁”或者“连接器"。也就是说
,当切实与像用户帐户这类安全相关数据进行交互,执行认证(登录)和授权(访问控制)时,Shiro会从应用配置的Realm中查找很多内容。
-->

<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="shiroSecurityRealm" /><!-- 由注解提供;shiro本身就提供了几个Realm,但一般我们自己实现 -->
</bean>

<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<!-- 在处理,没有登录的用户请求时,需要登录页面的话就会自动跳转到此页面 ;不是必要属性,不输入的话会自动寻找webroot下的login.jsp-->
<property name="loginUrl" value="/login.jsp"/>
<!-- 登录成功跳转页; -->
<property name="successUrl" value="/sys/sysuser/home"/>
<!-- 没有权限时跳转页 -->
<property name="unauthorizedUrl" value="/sys/sysuser/callUnauthorized"/>

<!-- value部分的 authc,roles只是filter的别名。如要更改别名,可以通过filters来改变。
把PassThruAuthenticationFilter添加别名为authc,这时/admin请求会交给PassThruAuthenticationFilter处理,
替换了原来由 FormAuthenticationFilter来处理。-->
<property name="filters">
<util:map>
<entry key="authc">
<bean class="org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter"/>
</entry>
</util:map>
</property>

<!-- filterChainDefinitions是对请求拦截的配置 -->
<property name="filterChainDefinitions">
<!-- 具体解释在最后
-->
<value>
/static/** = anon
/assets/** = anon
/index.jsp = anon
/login.jsp = anon
/sys/sysuser/login = anon
/sys/sysuser/register = anon
/sys/sysuser/retrievePassword = anon
/client/face = anon
/sys/sysuser/logout = logout
/** = authc
</value>
</property>
</bean>

<!-- Post processor that automatically invokes init() and destroy() methods -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>

</beans>

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧