码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2019-08-25 12:30:36      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:org   during   code   loader   tco   校验   ring   ade   start   

现象

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

标签:org   during   code   loader   tco   校验   ring   ade   start   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!