springBoot启动报initialize context because there is already a root application context present

在启动war类型的springBoot项目时报

java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml!

可以尝试在web.xml文件末尾添加

 <absolute-ordering/>

表示绝对顺序
示例

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:config/applicationContext.xml</param-value>
    </context-param>
    <!-- Spring监听器 -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    ***<absolute-ordering/>***
</web-app>

欢迎斧正。


版权声明:本文为qwe885167759原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。