springMVC中启动不了Tomcat问题1:More than one fragment with the name [spring_web] was found.

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 目录是一定会被扫描的。

https://blog.csdn.net/renfufei/article/details/70878077

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值