shiro 整合sping 报错Error creating bean with name 'shiroFilter'

big_bow 2016-11-19 02:25:50

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in URL [file:/F:/work/smc/target/Fiddle/WEB-INF/classes/spring-app.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory


spring-shiro.xml

<context:property-placeholder location="classpath:jdbc.properties" />
<bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
init-method="init" destroy-method="close">
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>

<!-- mybatis 的配置文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 -->
<property name="mapperLocations" value="classpath:mappers/*.xml"/>
</bean>

<!-- shiro 配置-->
<!-- 自定义realm -->
<bean name="securityRealm" class="com.realm.BaseRealm"/>


<!-- 安全管理器 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="securityRealm"/>
</bean>
<!-- Shiro过滤器 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<!-- Shiro的核心安全接口,这个属性是必须的 -->
<property name="securityManager" ref="securityManager"/>
<!-- 身份认证失败,则跳转到登录页面的配置 -->
<property name="loginUrl" value="/index.jsp"/>
<property name="successUrl" value="/"/>
<!-- 权限认证失败,则跳转到指定页面 -->
<property name="unauthorizedUrl" value="/401.jsp"/>
<!-- Shiro连接约束配置,即过滤链的定义 -->
<property name="filterChainDefinitions">
<value>
/login=anon
/** = authc
</value>
</property>
</bean>

<!-- 保证实现了Shiro内部lifecycle函数的bean执行 -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>

<!-- 开启Shiro注解 -->
<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>
<!-- shiro end -->


web.xml


<!-- 开启shiro 的支持 -->

<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<async-supported>true</async-supported>
<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>

<!-- 开启spring监听器 -->
<listener>
<description>springListener</description>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>


希望大神能帮忙看下,小弟不胜感激啊~
...全文
1193 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hlyjava 2017-04-26
  • 打赏
  • 举报
回复
我也是这个错,希望大神回答下
qq_35322167 2017-04-11
  • 打赏
  • 举报
回复
楼主问题解决了吗
胡xiao贤 2017-01-23
  • 打赏
  • 举报
回复
我想问下是不是Realm里面用了注解项目启动报了错 如果是就是配置文件少配置一个注解问题
能源恒观 2016-11-21
  • 打赏
  • 举报
回复
spring-app.xml这个配置文件相关的内容提出来看看,应该是配置出问题了
Mithiu 2016-11-21
  • 打赏
  • 举报
回复
把所有的错误都贴出来,理论上不止这点错误

81,092

社区成员

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

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