项目由mvn升级为cloud时,本地启动没问题,但发布到服务器就报Cannot initialize context because there is already a root application context present-check whether you have multiple ContextLoader* definitions in your web.xml!
具体异常如下图:
这个的坑有两点
首先日志是打印在localhost.*.log里面,不是平常常用的catline.out
其次日志里面的web.xml不仅仅指的你的项目或者jar包里面有web.xml定义了listener,还包括web-*.xml中定义的
具体解决方案就是全局搜索web.xml,然后把项目里面的这个文件删掉,或者有这个文件的jar包去掉,如果都去掉了,或者没有搜索到,那就搜索web-,然后找到对应的文件删掉,如通过web-搜索到了web-fragment.xml,这里面定义了listener,直接将这个删掉,或对应jar包排除即可。