首页 > 编程语言 > 详细

spring整合shiro配置BUG,Tomcat启动不了:Error during artifact deployment. See server log for details

时间:2019-08-25 12:47:51      阅读:112      评论:0      收藏:0      [点我收藏+]

现象

spring配置shiro权限控制之后,项目无法启动
[2019-08-09 09:00:35,800] Artifact export_web_manager:war exploded: Error during artifact deployment. See server log for details.

Tomcat起不来

原因

将shiro的spring配置放在了springmvc配置中,项目启动报错。
web.xml中的配置

    <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.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

<!--4. Shiro权限校验过滤器,这里的filter-name固定,对应spring容器中的过滤器工厂的bean的id-->
    <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>

web.xml的加载顺序是: <context-param>-> <listener> -> <filter> -> <servlet>。

当shiro的bean配置在springmvc.xml(从dispatcherServlet中加载xml)中,shiro相关的bean在filter加载的后面初始化

shiro配置的filter在容器中找不到相关实例,导致项目无法启动

解决

在web.xml中配置:

        <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:applicationContext-*.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

    </listener>

单独配置shiro的配置文件applicationContext-shiro.xml

spring整合shiro配置BUG,Tomcat启动不了:Error during artifact deployment. See server log for details

原文:https://www.cnblogs.com/tianzhen45/p/11407248.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!