spring整合shiro配置BUG,Tomcat启动不了:Error during artifact deployment. See server log for details
Posted tianzhen45
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring整合shiro配置BUG,Tomcat启动不了:Error during artifact deployment. See server log for details相关的知识,希望对你有一定的参考价值。
现象
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的主要内容,如果未能解决你的问题,请参考以下文章
[Shiro]Shiro整合Spring Boot 自动化配置