You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在WebSphere Liberty Core部署Spring Boot应用启动报错求助

解决WebSphere Liberty Core部署Spring Boot应用的CWWKC2262E错误

这个错误是因为你的应用中META-INF/web-fragment.xml使用了Servlet 4.0版本(对应命名空间http://xmlns.jcp.org/xml/ns/javaee),但当前WebSphere Liberty Core版本不兼容该版本的部署描述符。以下是几种解决思路:

  • 检查并升级Liberty版本
    Servlet 4.0属于Java EE 8规范,WebSphere Liberty Core需要至少18.0.0.2版本才支持。如果你的Liberty版本低于此,直接升级到支持Java EE 8的版本即可。

  • 移除不必要的web-fragment.xml
    如果你的Spring Boot应用不需要这个文件,通过Maven或Gradle打包配置排除生成它的依赖。以Maven为例,在pom.xml中添加打包插件配置:

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <!-- 替换为生成web-fragment.xml的依赖坐标 -->
                        <exclude>
                            <groupId>com.example</groupId>
                            <artifactId>problem-dependency</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
  • 降级web-fragment.xml版本
    若必须保留该文件,将其版本降级到Liberty支持的Servlet 3.1(Java EE 7),修改文件内容:

    <web-fragment 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-fragment_3_1.xsd"
                  version="3.1">
        <!-- 原有配置内容 -->
    </web-fragment>
    

    同时确保项目中Servlet API依赖版本与3.1匹配。

  • 启用Liberty对应Feature
    在Liberty的server.xml中添加支持Servlet 4.0的feature(如果已升级到兼容版本):

    <featureManager>
        <feature>servlet-4.0</feature>
        <!-- 根据Spring Boot版本添加对应springBoot feature,例如springBoot-2.7 -->
        <feature>springBoot-2.7</feature>
    </featureManager>
    

内容的提问来源于stack exchange,提问作者Mouafiq Abdelkabir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 21:07:04