[HTTP:101380]有多个同名网络片段:"spring_web"

[HTTP:101380]There is more than one Web fragment with the same name: "spring_web"

我试图将一个 spring MVC 项目部署到 WebLogic 12c,但我遇到了这个错误。

[HTTP:101380]There is more than one Web fragment with the same name: "spring_web".

这是我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">

<display-name>spring-mvc-demo</display-name>

<!-- Spring MVC Configs -->

<!-- Step 1: Configure Spring MVC Dispatcher Servlet -->
<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-mvc-demo-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- Step 2: Set up URL mapping for Spring MVC Dispatcher Servlet -->
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

这是我的 weblogic.xml

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.7/weblogic-web-app.xsd">
    <wls:weblogic-version>12.1.3</wls:weblogic-version>
    <wls:context-root>spring-mvc-demo</wls:context-root>
</wls:weblogic-web-app>

任何帮助将不胜感激。

解压缩由 maven 生成的 .war,并将其与 Eclipse 生成的进行比较。通常你必须告诉 maven 从某些工件中排除包,否则这些包将被打包两次(这几乎就是错误的意思 - 部署者已经遇到了一个具有特定名称的组件,并且这样做两次没有意义)

注意:如果您使用 maven 构建项目,以上给出的解决方案是一个可能的解决方案。

我遇到了这个问题,发现它是由重复的 JAR 文件引起的。我在 WAR 文件中有相同 JAR 的不同版本。

运行 mvn clean 修复了这个问题。

当我将版本从 2.1.6 更改为 2.0.6 时,我遇到了与 spring-boot 相同的问题。 运行 mvn clean 并再次构建应用程序解决了我的问题。

请参阅我们在 More than one fragment with the name [spring_web] was found / Cannot find the declaration of element 'beans' / server without internet access 的解决方案,其中涉及删除上下文文件中 xsd 标记中的错误 spring 版本和向 web.xml 添加绝对排序的组合。事实证明,重复的 spring 依赖项实际上并不需要存在,它们可以在上下文中被引用以引起问题。