spring项目中异常:Caused by: java.lang.IllegalArgumentException: More than one fragment with the name [spring_web] was found. This is not legal with relative ordering. See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering.
我的项目不包含多个Web片段,所以我不知道是什么导致了此问题。
这是网上找到的解决方法:将<absolute-ordering />
标签添加到标签的web.xml正下方<display-name>
。
![在这里插入图片描述](https://img-blog.csdnimg.cn/20191213095108429.png
参考:https://stackoverflow.com/questions/54290263/more-than-one-fragment-with-the-name-spring-web-was-found-this-is-not-legal-w
重点补充:
WEB-INF/web.xml 文件中可以指定两个选项:
设置 元素的属性 metadata-complete=“true”。
在其中添加一个空元素 。
设置 metadata-complete=“true” 可以禁止扫描 web应用和库类, 主要是对注解的扫描(例如 Servlet等)。 metadata-complete 选项并不能禁止所有的注解扫描. 加入存在 @HandlesTypes 注解的SCI, 则Tomcat 一定会扫描整个应用, 以确定使用对应注解的类和接口。
元素直接指定了哪些 JAR 包需要扫描 web fragment(在 WEB-INF/web-fragment.xml 文件中指定), 包括 SCI, fragment 以及 annotation. 元素是空的, 则表示一个类都不需要扫描。
在 Tomcat 7 中, absolute-ordering 选项同时影响应用程序的 SCI 和 容器提供的SCIs(即 $CATALINA_HOME/lib 中定义的)。在Tomcat 8 中, 容器提供的SCI总是会被扫描, 无论是否指定 absolute-ordering, 该选项只会影响到web应用. 这时候虽然 absolute-ordering 选项不能阻止注解扫描, 但扫描的列表是空的, 也就很快完成。 不论是否指定 absolute-ordering, WEB-INF/classes 目录是一定会被扫描的。